* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
[not found] <20250604095111.533783-1-kirill.shutemov@linux.intel.com>
@ 2025-06-04 9:56 ` Vlastimil Babka
2025-06-04 21:20 ` Andrew Morton
2025-06-04 15:40 ` Randy Dunlap
2025-06-04 15:49 ` Shakeel Butt
2 siblings, 1 reply; 8+ messages in thread
From: Vlastimil Babka @ 2025-06-04 9:56 UTC (permalink / raw)
To: Kirill A. Shutemov, Andrew Morton, David Hildenbrand
Cc: lorenzo.stoakes, Liam.Howlett, rppt, surenb, mhocko, hannes,
shakeel.butt, muchun.song, linux-mm, linux-kernel, Randy Dunlap,
Konstantin Khlebnikov
On 6/4/25 11:51, Kirill A. Shutemov wrote:
> When compiling with MEMCG enabled but VM_EVENT_COUNTERS disabled,
> BUILD_BUG_ON() is triggered in vmstat_start because the vmstat_text
> array is larger than NR_VMSTAT_ITEMS.
>
> This issue arises because some elements of the vmstat_text array are
> present when either MEMCG or VM_EVENT_COUNTERS is enabled, but
> NR_VMSTAT_ITEMS only accounts for these elements if VM_EVENT_COUNTERS is
> enabled.
>
> The recent change in the BUILD_BUG_ON() check made it more strict,
> disallowing extra elements in the array, which revealed the issue.
>
> Instead of adjusting the NR_VMSTAT_ITEMS definition to account for
> MEMCG, make MEMCG select VM_EVENT_COUNTERS. VM_EVENT_COUNTERS is
> enabled in most configurations anyway.
>
> There is no need to backport this fix to stable trees. Without the
> strict BUILD_BUG_ON(), the issue is not harmful. The elements in
> question would only be read by the memcg code, not by /proc/vmstat.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
Well in that case I think we should put Fixes: to the BUILD_BUG_ON() change.
And if it's not yet a stable sha1, squash that together with this?
It doesn't seem ebc5d83d0443 alone needs this fix.
> Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Otherwise,
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> include/linux/vmstat.h | 4 ++--
> init/Kconfig | 1 +
> mm/vmstat.c | 4 ++--
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
> index b2ccb6845595..c287998908bf 100644
> --- a/include/linux/vmstat.h
> +++ b/include/linux/vmstat.h
> @@ -507,7 +507,7 @@ static inline const char *lru_list_name(enum lru_list lru)
> return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> }
>
> -#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
> +#if defined(CONFIG_VM_EVENT_COUNTERS)
> static inline const char *vm_event_name(enum vm_event_item item)
> {
> return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> @@ -516,7 +516,7 @@ static inline const char *vm_event_name(enum vm_event_item item)
> NR_VM_STAT_ITEMS +
> item];
> }
> -#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +#endif /* CONFIG_VM_EVENT_COUNTERS */
>
> #ifdef CONFIG_MEMCG
>
> diff --git a/init/Kconfig b/init/Kconfig
> index ab83abe0fd9d..dd332cac6036 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -989,6 +989,7 @@ config MEMCG
> select PAGE_COUNTER
> select EVENTFD
> select SLAB_OBJ_EXT
> + select VM_EVENT_COUNTERS
> help
> Provides control over the memory footprint of tasks in a cgroup.
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 27dc37168cfd..c3114b8826e4 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1301,7 +1301,7 @@ const char * const vmstat_text[] = {
> [I(NR_MEMMAP_BOOT_PAGES)] = "nr_memmap_boot_pages",
> #undef I
>
> -#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
> +#if defined(CONFIG_VM_EVENT_COUNTERS)
> /* enum vm_event_item counters */
> #define I(x) (NR_VM_ZONE_STAT_ITEMS + NR_VM_NUMA_EVENT_ITEMS + \
> NR_VM_NODE_STAT_ITEMS + NR_VM_STAT_ITEMS + x)
> @@ -1498,7 +1498,7 @@ const char * const vmstat_text[] = {
> #endif
> #endif
> #undef I
> -#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +#endif /* CONFIG_VM_EVENT_COUNTERS */
> };
> #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
[not found] <20250604095111.533783-1-kirill.shutemov@linux.intel.com>
2025-06-04 9:56 ` [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n Vlastimil Babka
@ 2025-06-04 15:40 ` Randy Dunlap
2025-06-04 15:49 ` Shakeel Butt
2 siblings, 0 replies; 8+ messages in thread
From: Randy Dunlap @ 2025-06-04 15:40 UTC (permalink / raw)
To: Kirill A. Shutemov, Andrew Morton, David Hildenbrand
Cc: lorenzo.stoakes, Liam.Howlett, vbabka, rppt, surenb, mhocko,
hannes, shakeel.butt, muchun.song, linux-mm, linux-kernel,
Konstantin Khlebnikov
On 6/4/25 2:51 AM, Kirill A. Shutemov wrote:
> When compiling with MEMCG enabled but VM_EVENT_COUNTERS disabled,
> BUILD_BUG_ON() is triggered in vmstat_start because the vmstat_text
> array is larger than NR_VMSTAT_ITEMS.
>
> This issue arises because some elements of the vmstat_text array are
> present when either MEMCG or VM_EVENT_COUNTERS is enabled, but
> NR_VMSTAT_ITEMS only accounts for these elements if VM_EVENT_COUNTERS is
> enabled.
>
> The recent change in the BUILD_BUG_ON() check made it more strict,
> disallowing extra elements in the array, which revealed the issue.
>
> Instead of adjusting the NR_VMSTAT_ITEMS definition to account for
> MEMCG, make MEMCG select VM_EVENT_COUNTERS. VM_EVENT_COUNTERS is
> enabled in most configurations anyway.
>
> There is no need to backport this fix to stable trees. Without the
> strict BUILD_BUG_ON(), the issue is not harmful. The elements in
> question would only be read by the memcg code, not by /proc/vmstat.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
> Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.
> ---
> include/linux/vmstat.h | 4 ++--
> init/Kconfig | 1 +
> mm/vmstat.c | 4 ++--
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
> index b2ccb6845595..c287998908bf 100644
> --- a/include/linux/vmstat.h
> +++ b/include/linux/vmstat.h
> @@ -507,7 +507,7 @@ static inline const char *lru_list_name(enum lru_list lru)
> return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> }
>
> -#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
> +#if defined(CONFIG_VM_EVENT_COUNTERS)
> static inline const char *vm_event_name(enum vm_event_item item)
> {
> return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> @@ -516,7 +516,7 @@ static inline const char *vm_event_name(enum vm_event_item item)
> NR_VM_STAT_ITEMS +
> item];
> }
> -#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +#endif /* CONFIG_VM_EVENT_COUNTERS */
>
> #ifdef CONFIG_MEMCG
>
> diff --git a/init/Kconfig b/init/Kconfig
> index ab83abe0fd9d..dd332cac6036 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -989,6 +989,7 @@ config MEMCG
> select PAGE_COUNTER
> select EVENTFD
> select SLAB_OBJ_EXT
> + select VM_EVENT_COUNTERS
> help
> Provides control over the memory footprint of tasks in a cgroup.
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 27dc37168cfd..c3114b8826e4 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1301,7 +1301,7 @@ const char * const vmstat_text[] = {
> [I(NR_MEMMAP_BOOT_PAGES)] = "nr_memmap_boot_pages",
> #undef I
>
> -#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
> +#if defined(CONFIG_VM_EVENT_COUNTERS)
> /* enum vm_event_item counters */
> #define I(x) (NR_VM_ZONE_STAT_ITEMS + NR_VM_NUMA_EVENT_ITEMS + \
> NR_VM_NODE_STAT_ITEMS + NR_VM_STAT_ITEMS + x)
> @@ -1498,7 +1498,7 @@ const char * const vmstat_text[] = {
> #endif
> #endif
> #undef I
> -#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +#endif /* CONFIG_VM_EVENT_COUNTERS */
> };
> #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
>
--
~Randy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
[not found] <20250604095111.533783-1-kirill.shutemov@linux.intel.com>
2025-06-04 9:56 ` [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n Vlastimil Babka
2025-06-04 15:40 ` Randy Dunlap
@ 2025-06-04 15:49 ` Shakeel Butt
2 siblings, 0 replies; 8+ messages in thread
From: Shakeel Butt @ 2025-06-04 15:49 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Andrew Morton, David Hildenbrand, lorenzo.stoakes, Liam.Howlett,
vbabka, rppt, surenb, mhocko, hannes, muchun.song, linux-mm,
linux-kernel, Randy Dunlap, Konstantin Khlebnikov
On Wed, Jun 04, 2025 at 12:51:11PM +0300, Kirill A. Shutemov wrote:
> When compiling with MEMCG enabled but VM_EVENT_COUNTERS disabled,
> BUILD_BUG_ON() is triggered in vmstat_start because the vmstat_text
> array is larger than NR_VMSTAT_ITEMS.
>
> This issue arises because some elements of the vmstat_text array are
> present when either MEMCG or VM_EVENT_COUNTERS is enabled, but
> NR_VMSTAT_ITEMS only accounts for these elements if VM_EVENT_COUNTERS is
> enabled.
>
> The recent change in the BUILD_BUG_ON() check made it more strict,
> disallowing extra elements in the array, which revealed the issue.
>
> Instead of adjusting the NR_VMSTAT_ITEMS definition to account for
> MEMCG, make MEMCG select VM_EVENT_COUNTERS. VM_EVENT_COUNTERS is
> enabled in most configurations anyway.
>
> There is no need to backport this fix to stable trees. Without the
> strict BUILD_BUG_ON(), the issue is not harmful. The elements in
> question would only be read by the memcg code, not by /proc/vmstat.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
> Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
2025-06-04 9:56 ` [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n Vlastimil Babka
@ 2025-06-04 21:20 ` Andrew Morton
2025-06-05 6:19 ` Vlastimil Babka
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2025-06-04 21:20 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Kirill A. Shutemov, David Hildenbrand, lorenzo.stoakes,
Liam.Howlett, rppt, surenb, mhocko, hannes, shakeel.butt,
muchun.song, linux-mm, linux-kernel, Randy Dunlap,
Konstantin Khlebnikov
On Wed, 4 Jun 2025 11:56:42 +0200 Vlastimil Babka <vbabka@suse.cz> wrote:
> > There is no need to backport this fix to stable trees. Without the
> > strict BUILD_BUG_ON(), the issue is not harmful. The elements in
> > question would only be read by the memcg code, not by /proc/vmstat.
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
> > Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
>
> Well in that case I think we should put Fixes: to the BUILD_BUG_ON() change.
> And if it's not yet a stable sha1, squash that together with this?
> It doesn't seem ebc5d83d0443 alone needs this fix.
I shuffled things around.
I moved "mm: strictly check vmstat_text array size" from mm-hotfixes
and back into mm-new for the next cycle.
I reworked "mm/vmstat: fix build with MEMCG=y and VM_EVENT_COUNTERS=n"
so it precedes "mm: strictly check vmstat_text array size".
I reworked "mm/vmstat: utilize designated initializers for the
vmstat_text array" so it comes last.
So the applying order is now
mm-hotfixes:
mm-fix-vmstat-after-removing-nr_bounce.patch
mm-new:
mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch
mm-strictly-check-vmstat_text-array-size.patch
mm-vmstat-utilize-designated-initializers-for-the-vmstat_text-array.patch
and everything should land nicely.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
2025-06-04 21:20 ` Andrew Morton
@ 2025-06-05 6:19 ` Vlastimil Babka
2025-06-05 11:53 ` Kirill A. Shutemov
0 siblings, 1 reply; 8+ messages in thread
From: Vlastimil Babka @ 2025-06-05 6:19 UTC (permalink / raw)
To: Andrew Morton
Cc: Kirill A. Shutemov, David Hildenbrand, lorenzo.stoakes,
Liam.Howlett, rppt, surenb, mhocko, hannes, shakeel.butt,
muchun.song, linux-mm, linux-kernel, Randy Dunlap,
Konstantin Khlebnikov
On 6/4/25 23:20, Andrew Morton wrote:
> On Wed, 4 Jun 2025 11:56:42 +0200 Vlastimil Babka <vbabka@suse.cz> wrote:
>
>> > There is no need to backport this fix to stable trees. Without the
>> > strict BUILD_BUG_ON(), the issue is not harmful. The elements in
>> > question would only be read by the memcg code, not by /proc/vmstat.
>> >
>> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
>> > Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
>>
>> Well in that case I think we should put Fixes: to the BUILD_BUG_ON() change.
>> And if it's not yet a stable sha1, squash that together with this?
>> It doesn't seem ebc5d83d0443 alone needs this fix.
>
> I shuffled things around.
>
> I moved "mm: strictly check vmstat_text array size" from mm-hotfixes
> and back into mm-new for the next cycle.
>
> I reworked "mm/vmstat: fix build with MEMCG=y and VM_EVENT_COUNTERS=n"
> so it precedes "mm: strictly check vmstat_text array size".
>
> I reworked "mm/vmstat: utilize designated initializers for the
> vmstat_text array" so it comes last.
>
>
> So the applying order is now
I checked and in general it looks good, except a nit below.
> mm-hotfixes:
> mm-fix-vmstat-after-removing-nr_bounce.patch
>
> mm-new:
> mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch
> mm-strictly-check-vmstat_text-array-size.patch
The changelogs of these two don't reflect the new ordering though, maybe
Kirill can provide updated ones?
> mm-vmstat-utilize-designated-initializers-for-the-vmstat_text-array.patch
>
> and everything should land nicely.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
2025-06-05 6:19 ` Vlastimil Babka
@ 2025-06-05 11:53 ` Kirill A. Shutemov
2025-06-05 13:56 ` Vlastimil Babka
2025-06-05 21:50 ` Andrew Morton
0 siblings, 2 replies; 8+ messages in thread
From: Kirill A. Shutemov @ 2025-06-05 11:53 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Andrew Morton, David Hildenbrand, lorenzo.stoakes, Liam.Howlett,
rppt, surenb, mhocko, hannes, shakeel.butt, muchun.song, linux-mm,
linux-kernel, Randy Dunlap, Konstantin Khlebnikov
On Thu, Jun 05, 2025 at 08:19:28AM +0200, Vlastimil Babka wrote:
> On 6/4/25 23:20, Andrew Morton wrote:
> > On Wed, 4 Jun 2025 11:56:42 +0200 Vlastimil Babka <vbabka@suse.cz> wrote:
> >
> >> > There is no need to backport this fix to stable trees. Without the
> >> > strict BUILD_BUG_ON(), the issue is not harmful. The elements in
> >> > question would only be read by the memcg code, not by /proc/vmstat.
> >> >
> >> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
> >> > Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
> >>
> >> Well in that case I think we should put Fixes: to the BUILD_BUG_ON() change.
> >> And if it's not yet a stable sha1, squash that together with this?
> >> It doesn't seem ebc5d83d0443 alone needs this fix.
> >
> > I shuffled things around.
> >
> > I moved "mm: strictly check vmstat_text array size" from mm-hotfixes
> > and back into mm-new for the next cycle.
> >
> > I reworked "mm/vmstat: fix build with MEMCG=y and VM_EVENT_COUNTERS=n"
> > so it precedes "mm: strictly check vmstat_text array size".
> >
> > I reworked "mm/vmstat: utilize designated initializers for the
> > vmstat_text array" so it comes last.
> >
> >
> > So the applying order is now
>
> I checked and in general it looks good, except a nit below.
>
> > mm-hotfixes:
> > mm-fix-vmstat-after-removing-nr_bounce.patch
> >
> > mm-new:
> > mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch
> > mm-strictly-check-vmstat_text-array-size.patch
>
> The changelogs of these two don't reflect the new ordering though, maybe
> Kirill can provide updated ones?
Maybe something like this, for the first patch?
mm/vmstat: Make MEMCG select VM_EVENT_COUNTERS
The vmstat_text array contains labels for counters displayed in /proc/vmstat.
It is important to keep the labels in sync with the counters.
There is a BUILD_BUG_ON() check in vmstat_start() that ensures the size of the
vmstat_text is not smaller than VM_EVENT_COUNTERS. This helps to catch cases
where a new counter is added but the label is not. However, it does not help if
a counter is removed but the label remains.
It would be nice to make the BUILD_BUG_ON() check more strict to catch such
cases. However, when compiling with MEMCG enabled but VM_EVENT_COUNTERS
disabled, the vmstat_text array is larger than NR_VMSTAT_ITEMS.
This issue arises because some elements of the vmstat_text array are present
when either MEMCG or VM_EVENT_COUNTERS is enabled, but NR_VMSTAT_ITEMS only
accounts for these elements if VM_EVENT_COUNTERS is enabled.
Instead of adjusting the NR_VMSTAT_ITEMS definition to account for MEMCG, make
MEMCG select VM_EVENT_COUNTERS. VM_EVENT_COUNTERS is enabled in most
configurations anyway.
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
2025-06-05 11:53 ` Kirill A. Shutemov
@ 2025-06-05 13:56 ` Vlastimil Babka
2025-06-05 21:50 ` Andrew Morton
1 sibling, 0 replies; 8+ messages in thread
From: Vlastimil Babka @ 2025-06-05 13:56 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Andrew Morton, David Hildenbrand, lorenzo.stoakes, Liam.Howlett,
rppt, surenb, mhocko, hannes, shakeel.butt, muchun.song, linux-mm,
linux-kernel, Randy Dunlap, Konstantin Khlebnikov
On 6/5/25 13:53, Kirill A. Shutemov wrote:
> On Thu, Jun 05, 2025 at 08:19:28AM +0200, Vlastimil Babka wrote:
>> On 6/4/25 23:20, Andrew Morton wrote:
>> > On Wed, 4 Jun 2025 11:56:42 +0200 Vlastimil Babka <vbabka@suse.cz> wrote:
>> >
>> >> > There is no need to backport this fix to stable trees. Without the
>> >> > strict BUILD_BUG_ON(), the issue is not harmful. The elements in
>> >> > question would only be read by the memcg code, not by /proc/vmstat.
>> >> >
>> >> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> >> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
>> >> > Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
>> >>
>> >> Well in that case I think we should put Fixes: to the BUILD_BUG_ON() change.
>> >> And if it's not yet a stable sha1, squash that together with this?
>> >> It doesn't seem ebc5d83d0443 alone needs this fix.
>> >
>> > I shuffled things around.
>> >
>> > I moved "mm: strictly check vmstat_text array size" from mm-hotfixes
>> > and back into mm-new for the next cycle.
>> >
>> > I reworked "mm/vmstat: fix build with MEMCG=y and VM_EVENT_COUNTERS=n"
>> > so it precedes "mm: strictly check vmstat_text array size".
>> >
>> > I reworked "mm/vmstat: utilize designated initializers for the
>> > vmstat_text array" so it comes last.
>> >
>> >
>> > So the applying order is now
>>
>> I checked and in general it looks good, except a nit below.
>>
>> > mm-hotfixes:
>> > mm-fix-vmstat-after-removing-nr_bounce.patch
>> >
>> > mm-new:
>> > mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch
>> > mm-strictly-check-vmstat_text-array-size.patch
>>
>> The changelogs of these two don't reflect the new ordering though, maybe
>> Kirill can provide updated ones?
>
> Maybe something like this, for the first patch?
LGTM, thanks!
> > mm/vmstat: Make MEMCG select VM_EVENT_COUNTERS
>
> The vmstat_text array contains labels for counters displayed in /proc/vmstat.
> It is important to keep the labels in sync with the counters.
>
> There is a BUILD_BUG_ON() check in vmstat_start() that ensures the size of the
> vmstat_text is not smaller than VM_EVENT_COUNTERS. This helps to catch cases
> where a new counter is added but the label is not. However, it does not help if
> a counter is removed but the label remains.
>
> It would be nice to make the BUILD_BUG_ON() check more strict to catch such
> cases. However, when compiling with MEMCG enabled but VM_EVENT_COUNTERS
> disabled, the vmstat_text array is larger than NR_VMSTAT_ITEMS.
>
> This issue arises because some elements of the vmstat_text array are present
> when either MEMCG or VM_EVENT_COUNTERS is enabled, but NR_VMSTAT_ITEMS only
> accounts for these elements if VM_EVENT_COUNTERS is enabled.
>
> Instead of adjusting the NR_VMSTAT_ITEMS definition to account for MEMCG, make
> MEMCG select VM_EVENT_COUNTERS. VM_EVENT_COUNTERS is enabled in most
> configurations anyway.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n
2025-06-05 11:53 ` Kirill A. Shutemov
2025-06-05 13:56 ` Vlastimil Babka
@ 2025-06-05 21:50 ` Andrew Morton
1 sibling, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2025-06-05 21:50 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Vlastimil Babka, David Hildenbrand, lorenzo.stoakes, Liam.Howlett,
rppt, surenb, mhocko, hannes, shakeel.butt, muchun.song, linux-mm,
linux-kernel, Randy Dunlap, Konstantin Khlebnikov
On Thu, 5 Jun 2025 14:53:59 +0300 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
> > The changelogs of these two don't reflect the new ordering though, maybe
> > Kirill can provide updated ones?
>
> Maybe something like this, for the first patch?
>
>
> mm/vmstat: Make MEMCG select VM_EVENT_COUNTERS
>
> The vmstat_text array contains labels for counters displayed in /proc/vmstat.
> It is important to keep the labels in sync with the counters.
>
> ...
>
Updated, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-05 21:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250604095111.533783-1-kirill.shutemov@linux.intel.com>
2025-06-04 9:56 ` [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n Vlastimil Babka
2025-06-04 21:20 ` Andrew Morton
2025-06-05 6:19 ` Vlastimil Babka
2025-06-05 11:53 ` Kirill A. Shutemov
2025-06-05 13:56 ` Vlastimil Babka
2025-06-05 21:50 ` Andrew Morton
2025-06-04 15:40 ` Randy Dunlap
2025-06-04 15:49 ` Shakeel Butt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).