[PATCH v2 02/13] mm/slub: skip handle_failed_objexts_alloc() with profiling disabled
From: Vlastimil Babka (SUSE)
Date: Mon Jul 20 2026 - 10:28:15 EST
The function might get called with memory allocation profiling disabled,
when the obj_ext array is allocated for objcg pointers only. The
handling is however unnecessary in that case, so skip it.
This would otherwise become a real bug later, as pointed out by sashiko.
For now it's just an optimization.
Link: https://sashiko.dev/#/patchset/20260715-b4-objext_split-v1-0-9a49c4ccf4c3@xxxxxxxxxx?part=10
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
---
mm/slub.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 76acb78f2655..95fa6fbad11a 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2101,15 +2101,16 @@ static inline bool mark_failed_objexts_alloc(struct slab *slab)
static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
struct slabobj_ext *vec, unsigned int objects)
{
+ if (!mem_alloc_profiling_enabled())
+ return;
+
/*
* If vector previously failed to allocate then we have live
* objects with no tag reference. Mark all references in this
* vector as empty to avoid warnings later on.
*/
if (obj_exts == OBJEXTS_ALLOC_FAIL) {
- unsigned int i;
-
- for (i = 0; i < objects; i++)
+ for (unsigned int i = 0; i < objects; i++)
set_codetag_empty(&vec[i].ref);
}
}
--
2.55.0