[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c829f1fb-911a-41c8-9f78-371781f8e081@nvidia.com>
Date: Mon, 15 Sep 2025 12:37:51 +1000
From: Balbir Singh <balbirs@...dia.com>
To: David Hildenbrand <david@...hat.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Cc: damon@...ts.linux.dev, dri-devel@...ts.freedesktop.org,
Andrew Morton <akpm@...ux-foundation.org>, Zi Yan <ziy@...dia.com>,
Joshua Hahn <joshua.hahnjy@...il.com>, Rakie Kim <rakie.kim@...com>,
Byungchul Park <byungchul@...com>, Gregory Price <gourry@...rry.net>,
Ying Huang <ying.huang@...ux.alibaba.com>,
Alistair Popple <apopple@...dia.com>, Oscar Salvador <osalvador@...e.de>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Nico Pache <npache@...hat.com>,
Ryan Roberts <ryan.roberts@....com>, Dev Jain <dev.jain@....com>,
Barry Song <baohua@...nel.org>, Lyude Paul <lyude@...hat.com>,
Danilo Krummrich <dakr@...nel.org>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, Ralph Campbell <rcampbell@...dia.com>,
Mika Penttilä <mpenttil@...hat.com>,
Matthew Brost <matthew.brost@...el.com>,
Francois Dugast <francois.dugast@...el.com>
Subject: Re: [v5 03/15] mm/rmap: extend rmap and migration support
device-private entries
On 9/11/25 22:04, David Hildenbrand wrote:
> On 08.09.25 02:04, Balbir Singh wrote:
>
> subject:
>
> "mm/rmap: rmap and migration support for device-private PMD entries"
>
>
>> Add device-private THP support to reverse mapping infrastructure,
>> enabling proper handling during migration and walk operations.
>>
>> The key changes are:
>> - add_migration_pmd()/remove_migration_pmd(): Handle device-private
>> entries during folio migration and splitting
>> - page_vma_mapped_walk(): Recognize device-private THP entries during
>> VMA traversal operations
>>
>> This change supports folio splitting and migration operations on
>> device-private entries.
>>
>> Cc: Andrew Morton <akpm@...ux-foundation.org>
>> Cc: David Hildenbrand <david@...hat.com>
>> Cc: Zi Yan <ziy@...dia.com>
>> Cc: Joshua Hahn <joshua.hahnjy@...il.com>
>> Cc: Rakie Kim <rakie.kim@...com>
>> Cc: Byungchul Park <byungchul@...com>
>> Cc: Gregory Price <gourry@...rry.net>
>> Cc: Ying Huang <ying.huang@...ux.alibaba.com>
>> Cc: Alistair Popple <apopple@...dia.com>
>> Cc: Oscar Salvador <osalvador@...e.de>
>> Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
>> Cc: Baolin Wang <baolin.wang@...ux.alibaba.com>
>> Cc: "Liam R. Howlett" <Liam.Howlett@...cle.com>
>> Cc: Nico Pache <npache@...hat.com>
>> Cc: Ryan Roberts <ryan.roberts@....com>
>> Cc: Dev Jain <dev.jain@....com>
>> Cc: Barry Song <baohua@...nel.org>
>> Cc: Lyude Paul <lyude@...hat.com>
>> Cc: Danilo Krummrich <dakr@...nel.org>
>> Cc: David Airlie <airlied@...il.com>
>> Cc: Simona Vetter <simona@...ll.ch>
>> Cc: Ralph Campbell <rcampbell@...dia.com>
>> Cc: Mika Penttilä <mpenttil@...hat.com>
>> Cc: Matthew Brost <matthew.brost@...el.com>
>> Cc: Francois Dugast <francois.dugast@...el.com>
>>
>> Signed-off-by: Balbir Singh <balbirs@...dia.com>
>> ---
>
> [...]
>
>
>> +++ b/mm/page_vma_mapped.c
>> @@ -250,12 +250,11 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
>> pvmw->ptl = pmd_lock(mm, pvmw->pmd);
>> pmde = *pvmw->pmd;
>> if (!pmd_present(pmde)) {
>> - swp_entry_t entry;
>> + swp_entry_t entry = pmd_to_swp_entry(pmde);
>> if (!thp_migration_supported() ||
>> !(pvmw->flags & PVMW_MIGRATION))
>> return not_found(pvmw);
>> - entry = pmd_to_swp_entry(pmde);
>> if (!is_migration_entry(entry) ||
>> !check_pmd(swp_offset_pfn(entry), pvmw))
>> return not_found(pvmw);
>
> Why this change? Looks unrelated.
>
I fixed up and removed the new flag I introduced in v3. Will fix/undo
>> @@ -277,6 +276,15 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
>> * cannot return prematurely, while zap_huge_pmd() has
>> * cleared *pmd but not decremented compound_mapcount().
>
> Reminder to self: cleanup compound_mapcount() leftovers
>
>> */
>> + swp_entry_t entry;
>> +
>> + entry = pmd_to_swp_entry(pmde);
>
> swp_entry_t entry = pmd_to_swp_entry(pmde);
>
Ack
>> +
>> + if (is_device_private_entry(entry)) {
>> + pvmw->ptl = pmd_lock(mm, pvmw->pmd);
>> + return true;
>> + }
>> +
>> if ((pvmw->flags & PVMW_SYNC) &&
>> thp_vma_suitable_order(vma, pvmw->address,
>> PMD_ORDER) &&
>> diff --git a/mm/rmap.c b/mm/rmap.c
>> index 236ceff5b276..6de1baf7a4f1 100644
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -1063,8 +1063,10 @@ static int page_vma_mkclean_one(struct page_vma_mapped_walk *pvmw)
>> } else {
>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> pmd_t *pmd = pvmw->pmd;
>> - pmd_t entry;
>> + pmd_t entry = pmdp_get(pmd);
>> + if (!pmd_present(entry))
>> + continue;
>> if (!pmd_dirty(*pmd) && !pmd_write(*pmd))
>> continue;
>>
>
> If you just did a pmdp_get() you should use it in these functions as well. If not (cleanup later), do a straight *pmd like the others.
>
>
Ack
>
> Apart from that nothing jumped at me.
>
Thanks for the review,
Balbir
Powered by blists - more mailing lists