Re: [PATCH slab/for-next-fixes v3 2/4] mm/slab: decouple SLAB_NO_SHEAVES from SLAB_NO_OBJ_EXT
From: Suren Baghdasaryan
Date: Mon Jul 13 2026 - 11:41:24 EST
On Mon, Jul 13, 2026 at 7:29 AM Harry Yoo (Oracle) <harry@xxxxxxxxxx> wrote:
>
> Bootstrap caches are created with SLAB_NO_OBJ_EXT to disallow sheaves
> and obj_exts.
>
> To allow disabling obj_exts while allowing sheaves, decouple
> SLAB_NO_SHEAVES from SLAB_NO_OBJ_EXT. Bootstrap caches now have both
> SLAB_NO_SHEAVES and SLAB_NO_OBJ_EXT.
>
> No functional change intended.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: e47c897a2949 ("slab: add sheaves to most caches")
> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> Signed-off-by: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> ---
> include/linux/slab.h | 13 +++++++++++--
> mm/slub.c | 10 ++++++----
> 2 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 51f03f18c9a7..08d7b6c9c4d6 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -58,10 +58,13 @@ enum _slab_flag_bits {
> #endif
> _SLAB_OBJECT_POISON,
> _SLAB_CMPXCHG_DOUBLE,
> +#ifdef CONFIG_SLAB_OBJ_EXT
> _SLAB_NO_OBJ_EXT,
> -#if defined(CONFIG_SLAB_OBJ_EXT) && defined(CONFIG_64BIT)
> +#ifdef CONFIG_64BIT
> _SLAB_OBJ_EXT_IN_OBJ,
> #endif
> +#endif
> + _SLAB_NO_SHEAVES,
> _SLAB_FLAGS_LAST_BIT
> };
>
> @@ -239,8 +242,14 @@ enum _slab_flag_bits {
> #endif
> #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
>
> -/* Slab created using create_boot_cache */
> +/* Slab caches without obj_exts array */
> +#ifdef CONFIG_SLAB_OBJ_EXT
> #define SLAB_NO_OBJ_EXT __SLAB_FLAG_BIT(_SLAB_NO_OBJ_EXT)
> +#else
> +#define SLAB_NO_OBJ_EXT __SLAB_FLAG_UNUSED
> +#endif
> +
> +#define SLAB_NO_SHEAVES __SLAB_FLAG_BIT(_SLAB_NO_SHEAVES)
>
> #if defined(CONFIG_SLAB_OBJ_EXT) && defined(CONFIG_64BIT)
> #define SLAB_OBJ_EXT_IN_OBJ __SLAB_FLAG_BIT(_SLAB_OBJ_EXT_IN_OBJ)
> diff --git a/mm/slub.c b/mm/slub.c
> index f9461a0c47d3..abe748b7dddb 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -7799,12 +7799,12 @@ static unsigned int calculate_sheaf_capacity(struct kmem_cache *s,
> return 0;
>
> /*
> - * Bootstrap caches can't have sheaves for now (SLAB_NO_OBJ_EXT).
> + * Bootstrap caches can't have sheaves for now (SLAB_NO_SHEAVES).
> * SLAB_NOLEAKTRACE caches (e.g., kmemleak's object_cache) must not
> * have sheaves to avoid recursion when sheaf allocation triggers
> * kmemleak tracking.
> */
> - if (s->flags & (SLAB_NO_OBJ_EXT | SLAB_NOLEAKTRACE))
> + if (s->flags & (SLAB_NO_SHEAVES | SLAB_NOLEAKTRACE))
> return 0;
>
> /*
> @@ -8586,7 +8586,8 @@ void __init kmem_cache_init(void)
>
> create_boot_cache(kmem_cache_node, "kmem_cache_node",
> sizeof(struct kmem_cache_node),
> - SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0);
> + SLAB_HWCACHE_ALIGN | SLAB_NO_SHEAVES | SLAB_NO_OBJ_EXT,
> + 0, 0);
>
> hotplug_node_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
>
> @@ -8596,7 +8597,8 @@ void __init kmem_cache_init(void)
> create_boot_cache(kmem_cache, "kmem_cache",
> offsetof(struct kmem_cache, per_node) +
> nr_node_ids * sizeof(struct kmem_cache_per_node_ptrs),
> - SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0);
> + SLAB_HWCACHE_ALIGN | SLAB_NO_SHEAVES | SLAB_NO_OBJ_EXT,
> + 0, 0);
>
> kmem_cache = bootstrap(&boot_kmem_cache);
> kmem_cache_node = bootstrap(&boot_kmem_cache_node);
>
> --
> 2.53.0
>