Re: [PATCH mm-hotfixes] mm/huge_memory: use correct flags for device private PMD entry

From: David Hildenbrand (Arm)

Date: Mon Jun 01 2026 - 08:25:01 EST


On 6/1/26 10:55, Lorenzo Stoakes wrote:
> On Mon, Jun 01, 2026 at 09:30:44AM +0100, Lorenzo Stoakes wrote:
>> mm/huge_memory.c | 45 +++++++++++++++++++++++++++++++++------------
>> 1 file changed, 33 insertions(+), 12 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index bf9b480bb3b0..79463c709c98 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -4982,7 +4982,7 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
>> struct vm_area_struct *vma = pvmw->vma;
>> struct mm_struct *mm = vma->vm_mm;
>> unsigned long address = pvmw->address;
>> - bool anon_exclusive;
>> + bool anon_exclusive, present, writable, softdirty, uffd_wp;
>> pmd_t pmdval;
>> swp_entry_t entry;
>> pmd_t pmdswp;
>> @@ -4990,12 +4990,26 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
>> if (!(pvmw->pmd && !pvmw->pte))
>> return 0;
>>
>> - flush_cache_range(vma, address, address + HPAGE_PMD_SIZE);
>> - if (unlikely(!pmd_present(*pvmw->pmd)))
>> - pmdval = pmdp_huge_get_and_clear(vma->vm_mm, address, pvmw->pmd);
>> - else
>> + present = pmd_present(*pvmw->pmd);
>> + if (likely(present)) {
>> + flush_cache_range(vma, address, address + HPAGE_PMD_SIZE);
>
> Oh I forgot to mention in the commit message that I moved
> flush_cache_range() into the present branch, as it's not meaningful for a
> softleaf (i.e. non-present) entry.

Nothing jumped at me, so LGTM

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David