linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mm: Strictly check vmstat_text array size
       [not found] <20250529110541.2960330-1-kirill.shutemov@linux.intel.com>
@ 2025-05-29 12:16 ` Vlastimil Babka
  2025-05-29 12:26 ` Michal Hocko
  2025-05-30  9:50 ` David Hildenbrand
  2 siblings, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2025-05-29 12:16 UTC (permalink / raw)
  To: Kirill A. Shutemov, Andrew Morton, David Hildenbrand
  Cc: lorenzo.stoakes, Liam.Howlett, rppt, surenb, mhocko, linux-mm,
	linux-kernel, Konstantin Khlebnikov

On 5/29/25 13:05, Kirill A. Shutemov wrote:
> 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>

Yeah I don't see why it would be necessary to check only for missing labels.

Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  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;



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

* Re: [PATCH] mm: Strictly check vmstat_text array size
       [not found] <20250529110541.2960330-1-kirill.shutemov@linux.intel.com>
  2025-05-29 12:16 ` [PATCH] mm: Strictly check vmstat_text array size Vlastimil Babka
@ 2025-05-29 12:26 ` Michal Hocko
  2025-05-30  9:50 ` David Hildenbrand
  2 siblings, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2025-05-29 12:26 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, David Hildenbrand, lorenzo.stoakes, Liam.Howlett,
	vbabka, rppt, surenb, linux-mm, linux-kernel,
	Konstantin Khlebnikov

On Thu 29-05-25 14:05:41, Kirill A. Shutemov wrote:
> 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>

LGTM
Acked-by: Michal Hocko <mhocko@suse.com>

Not sure why we have gone with the current check TBH.

> ---
>  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

-- 
Michal Hocko
SUSE Labs


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

* Re: [PATCH] mm: Strictly check vmstat_text array size
       [not found] <20250529110541.2960330-1-kirill.shutemov@linux.intel.com>
  2025-05-29 12:16 ` [PATCH] mm: Strictly check vmstat_text array size Vlastimil Babka
  2025-05-29 12:26 ` Michal Hocko
@ 2025-05-30  9:50 ` David Hildenbrand
  2 siblings, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2025-05-30  9:50 UTC (permalink / raw)
  To: Kirill A. Shutemov, Andrew Morton
  Cc: lorenzo.stoakes, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-mm, linux-kernel, Konstantin Khlebnikov

On 29.05.25 13:05, Kirill A. Shutemov wrote:
> 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>
> ---

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250529110541.2960330-1-kirill.shutemov@linux.intel.com>
2025-05-29 12:16 ` [PATCH] mm: Strictly check vmstat_text array size 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