linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Ge Yang <yangge1116@126.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	21cnbao@gmail.com, david@redhat.com,
	baolin.wang@linux.alibaba.com, hannes@cmpxchg.org,
	liuzixing@hygon.cn
Subject: Re: [PATCH V3] mm: compaction: skip memory compaction when there are not enough migratable pages
Date: Tue, 14 Jan 2025 13:51:33 +0100	[thread overview]
Message-ID: <1ada3f6d-72bb-46a4-9fef-0bf6a7b32e62@suse.cz> (raw)
In-Reply-To: <c122f7a7-0aea-4fda-8621-21f765f0674d@126.com>

On 1/14/25 13:24, Ge Yang wrote:
>> Hopefully also when done from the pin_user_pages_remote(..., FOLL_LONGTERM,
>> ...) context the allocation gfp_mask correctly lacks __GFP_MOVABLE? 
> yes.
> I guess
>> it has to, otherwise it would allocate from the CMA pageblocks.
>> 
>> Then I wonder if we could use the real allocation context to determine
>> watermarks, as __compaction_suitable() is passing ALLOC_CMA instead because
>> it's checking only for migration targets, which have to be CMA compatible by
>> definition. But we could use the real unmovable allocation context to have
>> __zone_watermark_unusable_free() subtract CMA pages, and thus we won't pass
>> the order-0 check anymore once the non-CMA part is exhausted.
>> 
>> There's some risk that in some different scenario the compaction could in
>> fact migrate pages from the exhausted non-CMA part of the zone to the CMA
>> part and succeed, and we'll skip it instead. But that should be rare?
>> 
> Below is the previous discussion:
> https://lore.kernel.org/lkml/1734436004-1212-1-git-send-email-yangge1116@126.com/

Right so Johannes had the same concern.

>> Anyway given that concern I'm not sure about changing
>> __compaction_suitable() for every caller like this. We could (at least
>> initially) target this heuristic only for COMPACT_PRIO_ASYNC which is being
>> used for this THP opportunistic attempt.
>> 
>> So for example:
>> - add a new bool flag to compact_control that is true for COMPACT_PRIO_ASYNC
>> - pass cc pointer to compaction_suit_allocation_order()
>> - in that function, add another check if the the new cc flag is true,
>> between the current zone_watermark_ok() and compaction_suitable() checks,
>> which works like __compaction_suitable() but uses alloc_flags (which should
>> not be ALLOC_CMA in our pinned allocation case) instead of ALLOC_CMA, return
>> COMPACT_SKIPPED if it fails.
>> 
> I will send a new version of the patch based on the suggestions here. 
> Thank you.

Yeah that way should hopefully limit the concern sufficiently. Maybe we
could also add costly_order condition in addition to COMPACT_PRIO_ASYNC
condition to set the new compact_control flag. But only __GFP_NORETRY
allocations should be affected in the immediate "goto nopage" when
compaction is skipped, others will attempt with DEF_COMPACT_PRIORITY anyway
and won't fail without trying to compact-migrate the non-CMA pageblocks into
CMA pageblocks first, so it should be fine.



  reply	other threads:[~2025-01-14 12:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 11:30 yangge1116
2025-01-13  8:47 ` Barry Song
2025-01-13  9:02   ` Ge Yang
2025-01-13 10:05     ` Barry Song
2025-01-13 11:23       ` Ge Yang
2025-01-13 15:46 ` Johannes Weiner
2025-01-14  2:51   ` Ge Yang
2025-01-14 11:21 ` Vlastimil Babka
2025-01-14 12:24   ` Ge Yang
2025-01-14 12:51     ` Vlastimil Babka [this message]
2025-01-15  9:17       ` Ge Yang

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=1ada3f6d-72bb-46a4-9fef-0bf6a7b32e62@suse.cz \
    --to=vbabka@suse.cz \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuzixing@hygon.cn \
    --cc=yangge1116@126.com \
    /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