2 Matching Annotations
  1. Last 7 days
    1. watermark = (order > PAGE_ALLOC_COSTLY_ORDER) ? low_wmark_pages(zone) : min_wmark_pages(zone); watermark += compact_gap(order); return __zone_watermark_ok(zone, 0, watermark, highest_zoneidx, ALLOC_CMA, wmark_target);

      The __compaction_suitable function determines if memory compaction is viable for a given zone based on its current watermark levels and the requested allocation order. It calculates a watermark threshold, which varies depending on the allocation size, and includes a compaction gap for efficiency. The function then checks if the zone meets this watermark using __zone_watermark_ok, considering factors like CMA pages and zone indices. This check ensures that compaction is only attempted when there's sufficient free memory to make the process worthwhile, balancing the need for memory defragmentation against the computational cost of compaction.

    2. if (suitable) {

      This function implements a policy for determining when memory compaction is appropriate. It considers the allocation order, zone characteristics, and memory fragmentation level. For high-order allocations, it uses a fragmentation index and a configurable threshold to decide if compaction would be beneficial. The policy aims to balance the need for contiguous memory with system performance, avoiding unnecessary compaction that could impact system stability. It's more permissive for low-order allocations to prevent out-of-memory situations, while being more selective for high-order allocations to avoid excessive compaction overhead.