[PATCH v2 11/13] mm/slab: reduce slabobj_ext memory with allocation profiling disabled

From: Vlastimil Babka (SUSE)

Date: Mon Jul 20 2026 - 10:30:11 EST


When memory allocation profiling is compiled in but permanently disabled
on boot with (implicit or explicit) "never" parameter, stop allocating
(wasting) memory for the codetag_ref parts of slabobj_ext metadata.

Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
---
mm/slab.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/slab.h b/mm/slab.h
index 983cb1119a76..c5f37a46434e 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -591,7 +591,7 @@ static inline size_t cache_obj_ext_size(struct kmem_cache *s)
if (IS_ENABLED(CONFIG_MEMCG))
sz += 1;

- if (IS_ENABLED(CONFIG_MEM_ALLOC_PROFILING))
+ if (slab_obj_ext_has_codetag())
sz += 1;

return sizeof(struct slabobj_ext) * sz;

--
2.55.0