The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] mm: Strictly check vmstat_text array size
@ 2025-05-29 11:05 Kirill A. Shutemov
  2025-05-29 12:16 ` Vlastimil Babka
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2025-05-29 11:05 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: lorenzo.stoakes, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-mm, linux-kernel, Kirill A. Shutemov, Konstantin Khlebnikov

The /proc/vmstat displays counters from various sources. It is easy to
forget to add or remove a label when a new counter is added or removed.

There is a BUILD_BUG_ON() function that catches missing labels. However,
for some reason, it ignores extra labels.

Let's make the check strict. This would help to catch issues when
a counter is removed.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
---
 mm/vmstat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index ae9882063d89..0903adace423 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1867,7 +1867,7 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
 	if (*pos >= NR_VMSTAT_ITEMS)
 		return NULL;
 
-	BUILD_BUG_ON(ARRAY_SIZE(vmstat_text) < NR_VMSTAT_ITEMS);
+	BUILD_BUG_ON(ARRAY_SIZE(vmstat_text) != NR_VMSTAT_ITEMS);
 	fold_vm_numa_events();
 	v = kmalloc_array(NR_VMSTAT_ITEMS, sizeof(unsigned long), GFP_KERNEL);
 	m->private = v;
-- 
2.47.2


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

end of thread, other threads:[~2025-05-30  9:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 11:05 [PATCH] mm: Strictly check vmstat_text array size Kirill A. Shutemov
2025-05-29 12:16 ` Vlastimil Babka
2025-05-29 12:26 ` Michal Hocko
2025-05-30  9:50 ` David Hildenbrand

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