Re: [PATCH v4 2/2] mm/page_alloc: Clarify should_claim_block() commentary

From: Vlastimil Babka
Date: Fri Feb 28 2025 - 04:59:31 EST


On 2/28/25 10:52, Brendan Jackman wrote:
> There's lots of text here but it's a little hard to follow, this is an
> attempt to break it up and align its structure more closely with the
> code.
>
> Reword the top-level function comment to just explain what question the
> function answers from the point of view of the caller.
>
> Break up the internal logic into different sections that can have their
> own commentary describing why that part of the rationale is present.
>
> Note the page_group_by_mobility_disabled logic is not explained in the
> commentary, that is outside the scope of this patch...
>
> Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx>

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>

> + /*
> + * Unmovable/reclaimable allocations would cause permanent
> + * fragmentations if they fell back to allocating from a movable block
> + * (polluting it), so we try to claim the whole block regardless of the
> + * allocation size. Later movable allocations can always steal from this
> + * block, which is less problematic.
> + */
> + if (start_mt == MIGRATE_RECLAIMABLE || start_mt == MIGRATE_UNMOVABLE)
> + return true;
> +
> + if (page_group_by_mobility_disabled)
> + return true;
> +
> + /*
> + * Movable pages won't cause permanent fragmentation, so when you alloc

s/you/we/ for consistency? I think Andrew can amend locally to avoid resend.

Thanks.

> + * small pages, we just need to temporarily steal unmovable or
> + * reclaimable pages that are closest to the request size. After a
> + * while, memory compaction may occur to form large contiguous pages,
> + * and the next movable allocation may not need to steal.
> + */
> return false;
> }
>
>