Re: [PATCH v2 02/13] mm/slub: skip handle_failed_objexts_alloc() with profiling disabled
From: Harry Yoo
Date: Tue Jul 21 2026 - 01:52:34 EST
On 7/20/26 11:16 PM, Vlastimil Babka (SUSE) wrote:
> 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;
This looks racy.
Can we instead do this later in the series depending on
slab_obj_ext_has_codetag_key's value?
> /*
> * 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);
> }
> }
>
--
Cheers,
Harry / Hyeonggon
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature