[RFC 05/11] mm/memory/fault: Add support for zone device THP fault handling
Balbir Singh
balbirs at nvidia.com
Wed Jul 9 23:26:50 UTC 2025
On 7/9/25 00:40, David Hildenbrand wrote:
> On 06.03.25 05:42, Balbir Singh wrote:
>> When the CPU touches a zone device THP entry, the data needs to
>> be migrated back to the CPU, call migrate_to_ram() on these pages
>> via do_huge_pmd_device_private() fault handling helper.
>>
>> Signed-off-by: Balbir Singh <balbirs at nvidia.com>
>> ---
>> include/linux/huge_mm.h | 7 +++++++
>> mm/huge_memory.c | 35 +++++++++++++++++++++++++++++++++++
>> mm/memory.c | 6 ++++--
>> 3 files changed, 46 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
>> index e893d546a49f..ad0c0ccfcbc2 100644
>> --- a/include/linux/huge_mm.h
>> +++ b/include/linux/huge_mm.h
>> @@ -479,6 +479,8 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
>> vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf);
>> +vm_fault_t do_huge_pmd_device_private(struct vm_fault *vmf);
>> +
>> extern struct folio *huge_zero_folio;
>> extern unsigned long huge_zero_pfn;
>> @@ -634,6 +636,11 @@ static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
>> return 0;
>> }
>> +static inline vm_fault_t do_huge_pmd_device_private(struct vm_fault *vmf)
>> +{
>> + return 0;
>> +}
>> +
>> static inline bool is_huge_zero_folio(const struct folio *folio)
>> {
>> return false;
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index d8e018d1bdbd..995ac8be5709 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -1375,6 +1375,41 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf)
>> return __do_huge_pmd_anonymous_page(vmf);
>> }
>> +vm_fault_t do_huge_pmd_device_private(struct vm_fault *vmf)
>> +{
>> + struct vm_area_struct *vma = vmf->vma;
>> + unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
>> + vm_fault_t ret;
>> + spinlock_t *ptl;
>> + swp_entry_t swp_entry;
>> + struct page *page;
>> +
>> + if (!thp_vma_suitable_order(vma, haddr, PMD_ORDER))
>> + return VM_FAULT_FALLBACK;
>
> I'm confused. Why is that required when we already have a PMD entry?
>
> Apart from that, nothing jumped at me.
>
>
You're right, it is not required
Balbir Singh
More information about the Nouveau
mailing list