Re: [PATCH RFC 10/12] mm/slab: reduce slabobj_ext memory with allocation profiling disabled

From: Suren Baghdasaryan

Date: Thu Jul 16 2026 - 00:30:35 EST


On Wed, Jul 15, 2026 at 3:11 AM Vlastimil Babka (SUSE)
<vbabka@xxxxxxxxxx> wrote:
>
> 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.
>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>

Looks good but we should verify that slab allocation performance is
not regressed, especially if
CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=Y and then profiling was
disabled via "never" in the command line. I think that would be the
worst case scenario for performance.

Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>

> ---
> mm/slab.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/slab.h b/mm/slab.h
> index dcca86799fc9..a50347c9dbe3 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -587,7 +587,7 @@ static inline size_t static_obj_ext_size(void)
> 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
>