[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <451b72a3-8052-4dfb-84e7-1e97c3388db0@redhat.com>
Date: Mon, 20 Oct 2025 22:17:42 +0200
From: David Hildenbrand <david@...hat.com>
To: Gregory Price <gourry@...rry.net>
Cc: Zi Yan <ziy@...dia.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, kernel-team@...a.com,
akpm@...ux-foundation.org, vbabka@...e.cz, surenb@...gle.com,
mhocko@...e.com, jackmanb@...gle.com, hannes@...xchg.org
Subject: Re: [RFC PATCH] page_alloc: allow migration of smaller hugepages
during contig_alloc.
On 20.10.25 21:58, Gregory Price wrote:
> On Mon, Oct 20, 2025 at 09:46:21PM +0200, David Hildenbrand wrote:
>> On 20.10.25 21:40, Gregory Price wrote:
>>> On Mon, Oct 20, 2025 at 09:18:36PM +0200, David Hildenbrand wrote:
>>>>>
>>>>> 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.
>>>
>>> is snapshot_page() even worth it if we're already racing on flag checks?
>>
>> I think it tries to handle what compound_order() cannot easily handle, as it
>> will retry in case it detects an obvious race.
>>
>>>
>>> i.e. there's already a race condition between
>>>
>>> pfn_range_valid_contig(range) -> compaction(range)
>>
>> Can you elaborate how compaction comes into play here? I'm missing the
>> interaction.
>>
>> pfn_range_valid_contig() should be only called by alloc_contig_pages() and
>> not out of compaction context?
>>
>
> I've been digging through the code a bit, so a quick shot from my notes
>
> alloc_contig_pages_noprof
> if (pfn_range_valid_contig(range)) <- check validity
> __alloc_contig_pages(range)
> alloc_contig_range_noprof(range)
> start_isolate_page_range(range) <- isolate
> __alloc_contig_migrate_range(range)
> isolate_migratepages_range(range) <- compact
Oh, that's what you mean with "compact", it's just isolation+migration.
>
> Seems like all the checks done in pfn_range_valid_contig() already race
> with everything after it anyway since references aren't held? Any of
> those pages could be freed (get bogus values), but i suppose not
> allocated (given the zone lock is held)?
Yes, it's completely racy.
I was primarily concerned about us calling functions that will
VM_WARN_ON() etc due to the races; not that they would make us
accept/jump over a range although we shouldn't.
Of course, regarding the latter, we want to try as good as possible to
avoid jumping over ranges that we can actually handle.
--
Cheers
David / dhildenb
Powered by blists - more mailing lists