mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm: proc/task_mmu: Use walk_page_range_vma() for smaps
@ 2026-07-21  5:19 kaleshsingh
  2026-07-21 16:30 ` T.J. Mercier
  2026-07-22  0:39 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: kaleshsingh @ 2026-07-21  5:19 UTC (permalink / raw)
  To: surenb, akpm
  Cc: kernel-team, android-mm, Kalesh Singh, Liam R. Howlett,
	Lorenzo Stoakes, Vlastimil Babka, Jann Horn, Pedro Falcato,
	linux-mm, linux-kernel, linux-fsdevel

From: Kalesh Singh <kaleshsingh@google.com>

Modify smap_gather_stats() to use walk_page_range_vma() instead of
walk_page_range() when walking page tables.

walk_page_range() internally calls find_vma(), which asserts that
mmap_lock is held. This assertion fails when reading /proc/pid/smaps
under per-VMA locks (where mmap_lock is not held).

walk_page_range_vma() walks a range within a single VMA and does not
use find_vma(). It relies on the VMA lock instead (when configured
with PGWALK_VMA_RDLOCK_VERIFY), making it compatible with per-VMA
locks.

Fixes: ea3085dd7a4e ("fs/proc/task_mmu: read proc/pid/{smaps|numa_maps} under per-vma lock")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
---
 fs/proc/task_mmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index d32408f7cd5e..5d301bdd05fc 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1369,9 +1369,12 @@ static void smap_gather_stats(struct proc_maps_private *priv,
 			      struct mem_size_stats *mss, unsigned long start)
 {
 	const struct mm_walk_ops *ops = get_smaps_walk_ops(priv);
+	unsigned long end = vma->vm_end;
+
+	start = start ?: vma->vm_start;
 
 	/* Invalid start */
-	if (start >= vma->vm_end)
+	if (start >= end)
 		return;
 
 	if (vma == get_gate_vma(priv->lock_ctx.mm))
@@ -1401,10 +1404,7 @@ static void smap_gather_stats(struct proc_maps_private *priv,
 		}
 	}
 
-	if (!start)
-		walk_page_vma(vma, ops, mss);
-	else
-		walk_page_range(vma->vm_mm, start, vma->vm_end, ops, mss);
+	walk_page_range_vma(vma, start, end, ops, mss);
 
 	reacquire_rcu(priv);
 }

base-commit: b95f03f04d475aa6719d15a636ddf32222d55657
-- 
2.55.0.229.g6434b31f56-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-22 22:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-21  5:19 [PATCH] mm: proc/task_mmu: Use walk_page_range_vma() for smaps kaleshsingh
2026-07-21 16:30 ` T.J. Mercier
2026-07-21 19:39   ` Kalesh Singh
2026-07-22  0:39 ` Andrew Morton
2026-07-22  3:17   ` Suren Baghdasaryan
2026-07-22 22:25     ` Kalesh Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®