Re: [PATCH] mm/huge_memory: use READ_ONCE() when cloning folio flags during split
From: Zi Yan
Date: Thu Oct 29 2026 - 15:24:26 EST
On Thu Oct 29, 2026 at 10:54 AM EDT, David Hildenbrand (Arm) wrote:
> On 10/29/26 15:31, Zi Yan wrote:
>> On Thu Oct 29, 2026 at 6:47 AM EDT, David Hildenbrand (Arm) wrote:
>>> On 10/29/26 10:08, Barry Song wrote:
>>>>
>>>> I assume the race is harmless, but silencing KCSAN is still worthwhile.
>>
>> data_race() would work too.
>>
>>>
>>> Isn't there a way we could lose the PG_waiters flag?
>>
>> 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().
Fixes: c010d47f107f6 ("mm: thp: split huge page to any lower order pages").
Will send a patch soon.
--
Best Regards,
Yan, Zi