From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,vbabka@suse.cz,surenb@google.com,shakeel.butt@linux.dev,rppt@kernel.org,rdunlap@infradead.org,muchun.song@linux.dev,mhocko@suse.com,lorenzo.stoakes@oracle.com,liam.howlett@oracle.com,koct9i@gmail.com,hannes@cmpxchg.org,david@redhat.com,kirill.shutemov@linux.intel.com,akpm@linux-foundation.org
Subject: + mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch added to mm-new branch
Date: Wed, 04 Jun 2025 14:22:43 -0700 [thread overview]
Message-ID: <20250604212244.7C87DC4CEE4@smtp.kernel.org> (raw)
The patch titled
Subject: mm/vmstat: fix build with MEMCG=y and VM_EVENT_COUNTERS=n
has been added to the -mm mm-new branch. Its filename is
mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: mm/vmstat: fix build with MEMCG=y and VM_EVENT_COUNTERS=n
Date: Wed, 4 Jun 2025 12:51:11 +0300
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.
And upcoming 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.
Link: https://lkml.kernel.org/r/20250604095111.533783-1-kirill.shutemov@linux.intel.com
Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/vmstat.h | 4 ++--
init/Kconfig | 1 +
mm/vmstat.c | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
--- a/include/linux/vmstat.h~mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n
+++ a/include/linux/vmstat.h
@@ -507,7 +507,7 @@ static inline const char *lru_list_name(
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(
NR_VM_STAT_ITEMS +
item];
}
-#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
+#endif /* CONFIG_VM_EVENT_COUNTERS */
#ifdef CONFIG_MEMCG
--- a/init/Kconfig~mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n
+++ a/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.
--- a/mm/vmstat.c~mm-vmstat-fix-build-with-memcg=y-and-vm_event_counters=n
+++ a/mm/vmstat.c
@@ -1287,7 +1287,7 @@ const char * const vmstat_text[] = {
"nr_memmap_pages",
"nr_memmap_boot_pages",
-#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
+#if defined(CONFIG_VM_EVENT_COUNTERS)
/* enum vm_event_item counters */
"pgpgin",
"pgpgout",
@@ -1477,7 +1477,7 @@ const char * const vmstat_text[] = {
"kstack_rest",
#endif
#endif
-#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
+#endif /* CONFIG_VM_EVENT_COUNTERS */
};
#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
_
Patches currently in -mm which might be from kirill.shutemov@linux.intel.com are
mm-fix-vmstat-after-removing-nr_bounce.patch
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
reply other threads:[~2025-06-04 21:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250604212244.7C87DC4CEE4@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=koct9i@gmail.com \
--cc=liam.howlett@oracle.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=mm-commits@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=rdunlap@infradead.org \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.