linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Brendan Jackman <jackmanb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	Michal Hocko <mhocko@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Yosry Ahmed <yosry.ahmed@linux.dev>
Subject: Re: [PATCH v3 1/2] mm/page_alloc: Clarify terminology in migratetype fallback code
Date: Fri, 28 Feb 2025 10:25:27 +0100	[thread overview]
Message-ID: <bc14db89-378c-466e-935a-1b5d38264bb7@suse.cz> (raw)
In-Reply-To: <Z8A6v2V8l8c4VaSA@google.com>

On 2/27/25 11:13, Brendan Jackman wrote:
> On Wed, Feb 26, 2025 at 04:08:09PM +0100, Vlastimil Babka wrote:
>> On 2/25/25 4:29 PM, Brendan Jackman wrote:
>> >  /*
>> >   * When we are falling back to another migratetype during allocation, try to
>> > - * steal extra free pages from the same pageblocks to satisfy further
>> > - * allocations, instead of polluting multiple pageblocks.
>> > + * claim entire blocks to satisfy further allocations, instead of polluting
>> > + * multiple pageblocks.
>> >   *
>> > - * If we are stealing a relatively large buddy page, it is likely there will
>> > - * be more free pages in the pageblock, so try to steal them all. For
>> > - * reclaimable and unmovable allocations, we steal regardless of page size,
>> > - * as fragmentation caused by those allocations polluting movable pageblocks
>> > - * is worse than movable allocations stealing from unmovable and reclaimable
>> > - * pageblocks.
>> > + * If we are stealing a relatively large buddy page, it is likely there will be
>> > + * more free pages in the pageblock, so try to claim the whole block. For
>> > + * reclaimable and unmovable allocations, we claim the whole block regardless of
>> 
>> It's also "try to claim" here as it may still fail due to not enough
>> free/compatible pages even for those migratetypes. 
> 
> Yeah thanks, I seems worthwhile to be precise about this.
> 
>> Maybe the question
>> (out of scope of the patch) if they should get a lower threshold than
>> half. Before migratetype hygiene, the "we steal regardless" meant that
>> we really would steal all free pages even if not claiming the pageblock.
> 
> I wonder if there's some benefit to deciding when to claim blocks also
> based on the count of blocks per type or something? Like, if we're
> under memory pressure so all the freelists are empty, but there are
> already a bunch of unmovable blocks (that currently have movable pages
> in them), there's not much point in claiming a block, instead we'd
> prefer to reclaim/migrate those movable pages?

Hm we don't currently have counters for that, do we? But that would be the
feasible part. "that currently have movable pages in them" would be
expensive to determine, and an attempt to reclaim/migrate would be expensive
too. At best we could try kicking some asynchronous attempt I think.

>> > + * page size, as fragmentation caused by those allocations polluting movable
>> > + * pageblocks is worse than movable allocations stealing from unmovable and
>> > + * reclaimable pageblocks.
>> >   */
>> > -static bool can_steal_fallback(unsigned int order, int start_mt)
>> > +static bool should_claim_block(unsigned int order, int start_mt)
>> 
>> So technically it's should_try_claim_block() if we want to be precise
>> (but longer).
> 
> Yep, that seems worth it (especially given the function is effectively
> just an internal block of find_suitable_fallback()).
> 
>> >  {
>> >  	/*
>> >  	 * Leaving this order check is intended, although there is
>> >  	 * relaxed order check in next check. The reason is that
>> > -	 * we can actually steal whole pageblock if this condition met,
>> > +	 * we can actually claim the whole pageblock if this condition met,
>> 
>> try claiming
> 
> But I think in this case we really do claim unconditionally.

Ah right, thanks.


  reply	other threads:[~2025-02-28  9:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 15:29 [PATCH v3 0/2] mm/page_alloc: Some clarifications for migratetype fallback Brendan Jackman
2025-02-25 15:29 ` [PATCH v3 1/2] mm/page_alloc: Clarify terminology in migratetype fallback code Brendan Jackman
2025-02-26 15:08   ` Vlastimil Babka
2025-02-27 10:13     ` Brendan Jackman
2025-02-28  9:25       ` Vlastimil Babka [this message]
2025-02-25 15:29 ` [PATCH v3 2/2] mm/page_alloc: Clarify should_claim_block() commentary Brendan Jackman
2025-02-26 15:18   ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc14db89-378c-466e-935a-1b5d38264bb7@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=yosry.ahmed@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox