Re: [PATCH] mm/huge_memory: use READ_ONCE() when cloning folio flags during split

From: David Hildenbrand (Arm)

Date: Thu Oct 29 2026 - 15:25:04 EST


On 10/29/26 20:19, Zi Yan wrote:
> On Thu Oct 29, 2026 at 10:54 AM EDT, David Hildenbrand (Arm) wrote:
>> On 10/29/26 15:31, Zi Yan wrote:
>>>
>>> data_race() would work too.
>>>
>>>
>>> The PG_waiters on the original folio/the original head page is not lost,
>>
>> Ah, so it's not on arbitrary tail pages, just the old head.
>>
>>> but there is a chance PG_waiters is lost in the new head, because
>>> prep_compound_page() uses __SetPageHead() and can ignore the atomic set
>>> of PG_waiters.
>>
>> Fun.
>> ...>
>>> Solutions can be:
>>>
>>> 1. Use atomic SetPageHead() in prep_compound_page().
>>
>> That sounds like the right thing to do?
>
> Yes, simpler, but the atomic op can be costly at compound page init
> time. My plan is to add prep_compound_page_atomic() for
> __split_folio_to_order() and the atomic version SetPageHead().

Makes perfect sense.

--
Cheers,

David