From: David Hildenbrand <david@redhat.com>
To: Zi Yan <ziy@nvidia.com>, Gregory Price <gourry@gourry.net>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, akpm@linux-foundation.org, vbabka@suse.cz,
surenb@google.com, mhocko@suse.com, jackmanb@google.com,
hannes@cmpxchg.org
Subject: Re: [RFC PATCH] page_alloc: allow migration of smaller hugepages during contig_alloc.
Date: Mon, 20 Oct 2025 21:18:36 +0200 [thread overview]
Message-ID: <272c425a-b191-4eef-af6e-2bca1db7a940@redhat.com> (raw)
In-Reply-To: <609E7E01-33A6-4931-AC89-1F4B2944FB64@nvidia.com>
On 20.10.25 21:15, Zi Yan wrote:
> On 20 Oct 2025, at 13:41, Gregory Price wrote:
>
>> On Mon, Oct 20, 2025 at 07:24:04PM +0200, David Hildenbrand wrote:
>>> On 20.10.25 19:06, Gregory Price wrote:
>>>
>>> Do we really need the folio_hugetlb_migratable() check?
>>> This code is completely racy.
>>
>> My thought was it's better to check if any *one* folio in the bunch is
>> non-migratable, it's better to never even call compaction in the first
>> place. But you're right, this is racy.
>>
>> In one race, the compaction code will just fail if this bit gets set
>> between now and the isolate call in folio_isolate_hugetlb() - resulting
>> in searching the next block anyway. So that seemed ok?
>>
>> In the other race, the bit becomes un-set and we skip a block that might
>> otherwise be valid.
>>
>> I can drop this check, it's just an optimistic optimization anyway.
>>
>> I should also probably check CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION here
>> regardless, since we should skip compaction if migration isn't possible.
>>
>>>> folio_nr_pages() should be fine AFAIKT (no
>>> VM_WARN_ON() etc), not sure about folio_test_hugetlb_migratable().
>>
>> will change, and will check/change based on above thoughts.
>
> If it is racy, could folio_order() or folio_nr_pages() return a bogusly
> large and cause a wrong result?
>
> In isolate_migratepages_block(), compound_order(page) is used and checked
> against MAX_PAGE_ORDER to avoid a bogus page order. I wonder if we should
> use the same pattern here.
>
> Basically, what is the right way of checking a folio order without lock?
> Should we have a standardized helper function for that?
As raised, snapshot_page() tries to stabilize the folio best it can.
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-10-20 19:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 17:06 [RFC PATCH] page_alloc: allow migration of smaller hugepages during contig_alloc Gregory Price
2025-10-20 17:24 ` David Hildenbrand
2025-10-20 17:41 ` Gregory Price
2025-10-20 19:15 ` Zi Yan
2025-10-20 19:18 ` David Hildenbrand [this message]
2025-10-20 19:40 ` Gregory Price
2025-10-20 19:46 ` David Hildenbrand
2025-10-20 19:58 ` Gregory Price
2025-10-20 20:17 ` David Hildenbrand
2025-10-20 20:27 ` Gregory Price
2025-10-20 20:38 ` David Hildenbrand
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=272c425a-b191-4eef-af6e-2bca1db7a940@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.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;
as well as URLs for NNTP newsgroup(s).