Re: [PATCH 3/3] fs/proc/task_mmu: account device-private PMDs as present in smaps
From: Lorenzo Stoakes (ARM)
Date: Wed Nov 11 2026 - 08:48:46 EST
On Wed, Nov 11, 2026 at 03:38:31AM -0800, Usama Arif wrote:
> Device-private PMDs represent mapped pages, but smaps_pmd_entry()
> passes present=false to smaps_account(). That treats them like migration
> entries: mapcounts are ignored, PSS is charged in full, and exclusive
> mappings are accounted as shared.
>
> Match smaps_pte_entry() and mark device-private PMDs as present so
> smaps_account() uses mapcounts for PSS and private/shared accounting.
>
> Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
It feels like PMD level device private entries have been the source of a lot of
issues, maybe a good area to audit in general... :)
Acked-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
> ---
> fs/proc/task_mmu.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index c0d391186c2b8..ad97532fc1184 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -1032,8 +1032,11 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
> } else if (unlikely(thp_migration_supported())) {
> const softleaf_t entry = softleaf_from_pmd(*pmd);
>
> - if (softleaf_has_pfn(entry))
> + if (softleaf_has_pfn(entry)) {
> + if (softleaf_is_device_private(entry))
> + present = true;
> page = softleaf_to_page(entry);
> + }
> }
> if (IS_ERR_OR_NULL(page))
> return;
> --
> 2.53.0-Meta
>
--
Cheers, Lorenzo