Re: [RESEND v7 10/29] mm: make PMD migration-entry splitting explicit

From: Usama Arif

Date: Thu Sep 24 2026 - 13:00:03 EST




On 23/09/2026 12:04, David Hildenbrand (Arm) wrote:
> Having another look ...
>
>
>> +
>> +/*
>> + * Split a present PMD into PTE migration entries, for the rmap migration
>> + * walker.
>
> I assume pmd_is_device_private_entry() is also allowed?
>
> "present or device-private PMDs"
>

Yes, ack.

>
>> Like split_huge_pmd_locked(), the caller must hold the PMD lock and
>> + * must already be inside an mmu_notifier invalidate range.
>> + */
>> +void split_pmd_to_migration_entries(struct vm_area_struct *vma,
>> + unsigned long address, pmd_t *pmd)
>> +{
>> + VM_WARN_ON_ONCE(!IS_ALIGNED(address, HPAGE_PMD_SIZE));
>> + if (pmd_trans_huge(*pmd) || pmd_is_valid_softleaf(*pmd))
>
> pmd_is_valid_softleaf() would include migration entries and swap entries?
>
> I'd assume that try_to_migrate_one() will never call us with something that is
> not a present or device-private PMD?
>
> Shouldn't we instead just
>
>
> VM_WARN_ON_ONCE(!pmd_present(*pmd) && !pmd_is_device_private_entry(*pmd));
> __split_huge_pmd_locked(vma, pmd, address, true);
>
> And not offer some weird fallback where we silently don't split?


Yes, that sounds much better. The function right now is:


/**
* split_pmd_to_migration_entries() - Split a present or device private PMD into
* PTE migration entries.
* @vma: The VMA containing the PMD.
* @address: The PMD-aligned address the PMD maps.
* @pmd: A pointer to the leaf PMD entry.
*
* For the rmap migration walker, which only ever hands back those two entry
* types. Like split_huge_pmd_locked(), the caller must hold the PMD lock and
* must already be inside an mmu_notifier invalidate range.
*/
void split_pmd_to_migration_entries(struct vm_area_struct *vma,
unsigned long address, pmd_t *pmd)
{
VM_WARN_ON_ONCE(!IS_ALIGNED(address, HPAGE_PMD_SIZE));
VM_WARN_ON_ONCE(!pmd_present(*pmd) &&
!pmd_is_device_private_entry(*pmd));
__split_huge_pmd_locked(vma, pmd, address, true);
}

>
>> + __split_huge_pmd_locked(vma, pmd, address, true);
>> }
>