Re: [PATCH 2/4] mm/huge_memory: add page->private check back in __split_folio_to_order()
From: Zi Yan
Date: Mon Jun 29 2026 - 11:15:03 EST
On 29 Jun 2026, at 10:39, Vlastimil Babka (SUSE) wrote:
> On 6/29/26 04:56, Zi Yan wrote:
>> page->private should not be set in tail pages. Commit 4265d67e405a
>> ("mm/migrate_device: add THP splitting during migration") removed it
>> without a proper reason. Add it back.
>>
>> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
>> ---
>> mm/huge_memory.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 2bccb0a53a0a..037d67fbec6e 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -3594,6 +3594,16 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
>> new_folio->mapping = folio->mapping;
>> new_folio->index = folio->index + i;
>>
>> + /*
>> + * page->private should not be set in tail pages. Fix up and warn once
>> + * if private is unexpectedly set. Do it before swap.val assignment
>> + * since private overlaps with swap.val.
>> + */
>> + if (unlikely(new_folio->private)) {
>> + VM_WARN_ON_ONCE_PAGE(true, new_head);
>> + new_folio->private = NULL;
>> + }
>
> The unconditional warning means this is not expected to happen. In that case
> it's odd to check and fixup always, but only warn with CONFIG_DEBUG_VM.
>
> If we are reasonably sure the current code is OK, and only want to catch new
> mistakes in development, we could just VM_WARN_ON_ONCE_PAGE() without fixup.
>
> If we are paranoid, leave it as it is, but drop the "VM_" ?
OK, let me drop the fixup unless others have a different thought.
>
>> +
>> if (folio_test_swapcache(folio))
>> new_folio->swap.val = folio->swap.val + i;
>>
>>
Best Regards,
Yan, Zi