#author("2025-09-11T11:07:49+09:00","default:guest","guest")
#author("2025-09-11T11:20:02+09:00","default:guest","guest")
*参照元 [#cb8cc65f]
#backlinks

*説明 [#s64e2f94]
-パス: [[linux-5.15/mm/compaction.c]]

-FIXME: これは何?
--説明
-指定したゾーン、オーダー、割当フラグにおいて、コンパクションを行うかどうかを取得する。


**引数 [#c9a3a281]
-
--
-struct zone *zone
--メモリゾーン。
--[[linux-5.15/zone]]
-int order
--オーダー
-unsigned int alloc_flags
--割当フラグ
-int highest_zoneidx
--この値以下のゾーンから割り当てる


**返り値 [#wc1d1b93]
-
--
-enum compact_result
--COMPACT_SKIPPED  - コンパクションするための空きページが足りない(のでコンパクションしない)
--COMPACT_SUCCESS  - コンパクションしなくても割当が成功する(のでコンパクションしない)
--COMPACT_CONTINUE - コンパクションすべき


**参考 [#c767d3fd]


*実装 [#fd42e6cf]

 /*
  * compaction_suitable: Is this suitable to run compaction on this zone now?
  * Returns
  *   COMPACT_SKIPPED  - If there are too few free pages for compaction
  *   COMPACT_SUCCESS  - If the allocation would succeed without compaction
  *   COMPACT_CONTINUE - If compaction should run now
  */
 enum compact_result compaction_suitable(struct zone *zone, int order,
 					unsigned int alloc_flags,
 					int highest_zoneidx)
 {
 	enum compact_result ret;
 	int fragindex;
 
 	ret = __compaction_suitable(zone, order, alloc_flags, highest_zoneidx,
 				    zone_page_state(zone, NR_FREE_PAGES));
-
--[[linux-5.15/__compaction_suitable()]]
--[[linux-5.15/zone_page_state()]]

 	/*
 	 * fragmentation index determines if allocation failures are due to
 	 * low memory or external fragmentation
 	 *
 	 * index of -1000 would imply allocations might succeed depending on
 	 * watermarks, but we already failed the high-order watermark check
 	 * index towards 0 implies failure is due to lack of memory
 	 * index towards 1000 implies failure is due to fragmentation
 	 *
 	 * Only compact if a failure would be due to fragmentation. Also
 	 * ignore fragindex for non-costly orders where the alternative to
 	 * a successful reclaim/compaction is OOM. Fragindex and the
 	 * vm.extfrag_threshold sysctl is meant as a heuristic to prevent
 	 * excessive compaction for costly orders, but it should not be at the
 	 * expense of system stability.
 	 */
 	if (ret == COMPACT_CONTINUE && (order > PAGE_ALLOC_COSTLY_ORDER)) {
 		fragindex = fragmentation_index(zone, order);
 		if (fragindex >= 0 && fragindex <= sysctl_extfrag_threshold)
 			ret = COMPACT_NOT_SUITABLE_ZONE;
 	}
 
-
--[[linux-5.15/fragmentation_index()]]

 	trace_mm_compaction_suitable(zone, order, ret);
 	if (ret == COMPACT_NOT_SUITABLE_ZONE)
 		ret = COMPACT_SKIPPED;
 
 	return ret;
 }

-
--[[linux-5.15/trace_mm_compaction_suitable()]]


*コメント [#cb4b6f63]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS