linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: add stack trace when bad rss-counter state is detected
@ 2025-07-23  7:23 Xuanye Liu
  2025-07-23  7:31 ` Kees Cook
  0 siblings, 1 reply; 12+ messages in thread
From: Xuanye Liu @ 2025-07-23  7:23 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Kees Cook, Andrew Morton, David Hildenbrand
  Cc: Xuanye Liu, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-mm, linux-kernel

The check_mm() function verifies the correctness of rss counters in
struct mm_struct. Currently, it only prints an alert when a bad
rss-counter state is detected, but lacks sufficient context for
debugging.

This patch adds a dump_stack() call to provide a stack trace when
the rss-counter state is invalid. This helps developers identify
where the corrupted mm_struct is being checked and trace the
underlying cause of the inconsistency.

Signed-off-by: Xuanye Liu <liuqiye2025@163.com>
---
 kernel/fork.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index cfe2f1df5f27..d38f1c5270ea 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -584,9 +584,11 @@ static void check_mm(struct mm_struct *mm)
 	for (i = 0; i < NR_MM_COUNTERS; i++) {
 		long x = percpu_counter_sum(&mm->rss_stat[i]);
 
-		if (unlikely(x))
+		if (unlikely(x)) {
 			pr_alert("BUG: Bad rss-counter state mm:%p type:%s val:%ld\n",
 				 mm, resident_page_types[i], x);
+			dump_stack();
+		}
 	}
 
 	if (mm_pgtables_bytes(mm))
-- 
2.43.0



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

end of thread, other threads:[~2025-07-23  9:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-23  7:23 [PATCH] mm: add stack trace when bad rss-counter state is detected Xuanye Liu
2025-07-23  7:31 ` Kees Cook
2025-07-23  7:45   ` Xuanye Liu
2025-07-23  8:05     ` David Hildenbrand
2025-07-23  8:42       ` David Hildenbrand
2025-07-23  9:10         ` Xuanye Liu
2025-07-23  9:14           ` Xuanye Liu
2025-07-23  9:22             ` Lorenzo Stoakes
2025-07-23  9:31               ` Xuanye Liu
2025-07-23  9:17           ` Vlastimil Babka
2025-07-23  9:23             ` Lorenzo Stoakes
2025-07-23  9:25             ` David Hildenbrand

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