[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240710015608.100801-1-alexs@kernel.org>
Date: Wed, 10 Jul 2024 09:56:08 +0800
From: alexs@...nel.org
To: Christoph Lameter <cl@...ux.com>,
Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Vlastimil Babka <vbabka@...e.cz>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Hyeonggon Yoo <42.hyeyoo@...il.com>,
"Gustavo A . R . Silva" <gustavoars@...nel.org>,
Vincent Guittot <vincent.guittot@...aro.org>,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Cc: Petr Mladek <pmladek@...e.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
Yoann Congal <yoann.congal@...le.fr>,
"Alex Shi (Tencent)" <alexs@...nel.org>,
Suren Baghdasaryan <surenb@...gle.com>
Subject: [PATCH v2] mm/memcg: alignment memcg_data define condition
From: "Alex Shi (Tencent)" <alexs@...nel.org>
commit 21c690a349ba ("mm: introduce slabobj_ext to support slab object
extensions") changed the folio/page->memcg_data define condition from
MEMCG to SLAB_OBJ_EXT. And selected SLAB_OBJ_EXT for MEMCG, just for
SLAB_MATCH(memcg_data, obj_exts), even no other relationship between them.
Above action make memcg_data exposed and include SLAB_OBJ_EXT for
!MEMCG. That's incorrect in logcial and pay on code size.
So let's remove SLAB_OBJ_EXT from MEMCG and as Vlastimil Babka suggested,
add _unused_slab_obj_ext for SLAB_MATCH for slab.obj_exts while !MEMCG.
That could resolve the match issue, clean up the feature logical and
save the unnessary code adding.
Signed-off-by: Alex Shi (Tencent) <alexs@...nel.org>
Cc: Randy Dunlap <rdunlap@...radead.org>
Cc: Yoann Congal <yoann.congal@...le.fr>
Cc: Masahiro Yamada <masahiroy@...nel.org>
Cc: Petr Mladek <pmladek@...e.com>
Cc: Suren Baghdasaryan <surenb@...gle.com>
Cc: Vlastimil Babka <vbabka@...e.cz>
---
include/linux/mm_types.h | 8 ++++++--
init/Kconfig | 1 -
mm/slab.h | 4 ++++
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index ef09c4eef6d3..4ac3abc673d3 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -180,8 +180,10 @@ struct page {
/* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */
atomic_t _refcount;
-#ifdef CONFIG_SLAB_OBJ_EXT
+#ifdef CONFIG_MEMCG
unsigned long memcg_data;
+#elif defined(CONFIG_SLAB_OBJ_EXT)
+ unsigned long _unused_slab_obj_ext;
#endif
/*
@@ -343,8 +345,10 @@ struct folio {
};
atomic_t _mapcount;
atomic_t _refcount;
-#ifdef CONFIG_SLAB_OBJ_EXT
+#ifdef CONFIG_MEMCG
unsigned long memcg_data;
+#elif defined(CONFIG_SLAB_OBJ_EXT)
+ unsigned long _unused_slab_obj_ext;
#endif
#if defined(WANT_PAGE_VIRTUAL)
void *virtual;
diff --git a/init/Kconfig b/init/Kconfig
index 26bf8bb0a7ce..61e43ac9fe75 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -965,7 +965,6 @@ config MEMCG
bool "Memory controller"
select PAGE_COUNTER
select EVENTFD
- select SLAB_OBJ_EXT
help
Provides control over the memory footprint of tasks in a cgroup.
diff --git a/mm/slab.h b/mm/slab.h
index 3586e6183224..8ffdd4f315f8 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -98,7 +98,11 @@ SLAB_MATCH(flags, __page_flags);
SLAB_MATCH(compound_head, slab_cache); /* Ensure bit 0 is clear */
SLAB_MATCH(_refcount, __page_refcount);
#ifdef CONFIG_SLAB_OBJ_EXT
+#ifdef CONFIG_MEMCG
SLAB_MATCH(memcg_data, obj_exts);
+#else
+SLAB_MATCH(_unused_slab_obj_ext, obj_exts);
+#endif
#endif
#undef SLAB_MATCH
static_assert(sizeof(struct slab) <= sizeof(struct page));
--
2.43.0
Powered by blists - more mailing lists