mm/memcg: alignment memcg_data define condition
Subsystems (3)
PATCH v2 1/1 mm/memcg: alignment memcg_data define condition
From: "Alex Shi (Tencent)" <[email protected]>
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.
--- include/linux/mm_types.h | 8 ++++++-- init/Kconfig | 1 - mm/slab.h | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-)
include/linux/mm_types.h +6 -2
@@ -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;
init/Kconfig +0 -1
@@ -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.
mm/slab.h +4 -0
@@ -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_MATCHstatic_assert (sizeof (struct slab ) <=sizeof (struct page ));
Signature · 1 line
2.43.0
Ops,
This patch failed with MEMCG && !SLAB_OBJ_EXT, please ignore this patch, I will update ASAP.
Sorry
Quoted 84 lines · On 7/10/24 9:56 AM, [email protected] wrote:
From: "Alex Shi (Tencent)" <[email protected]>
commit
21c690a349ba("mm: introduceslabobj_extto support slab object extensions") changed the folio/page->memcg_data define condition from MEMCG toSLAB_OBJ_EXT. And selectedSLAB_OBJ_EXTfor MEMCG, just forSLAB_MATCH(memcg_data, obj_exts), even no other relationship between them.Above action make
memcg_dataexposed and includeSLAB_OBJ_EXTfor !MEMCG. That's incorrect in logcial and pay on code size.So let's remove
SLAB_OBJ_EXTfrom MEMCG and as Vlastimil Babka suggested, add_unused_slab_obj_extforSLAB_MATCHfor 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) <[email protected]>Cc Randy Dunlap <[email protected]>Cc Yoann Congal <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Petr Mladek <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Vlastimil Babka <[email protected]>--- include/linux/mm_types.h | 8 ++++++-- init/Kconfig | 1 - mm/slab.h | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-)include/linux/mm_types.h +6
-2@@ -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;init/Kconfig +0
-1@@ -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.mm/slab.h +4
-0@@ -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_MATCHstatic_assert (sizeof (struct slab ) <=sizeof (struct page ));