Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/slab: only allow SLAB_OBJ_EXT_IN_OBJ for unmergeable caches

While SLAB_OBJ_EXT_IN_OBJ allows to reduce memory overhead to account
slab objects, it prevents slab merging because merging can change
the metadata layout.

As pointed out Vlastimil Babka, disabling merging solely for this memory
optimization may not be a net win, because disabling slab merging tends
to increase overall memory usage.

Restrict SLAB_OBJ_EXT_IN_OBJ to caches that are already unmergeable for
other reasons (e.g., those with constructors or SLAB_TYPESAFE_BY_RCU).

Suggested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
Link: https://patch.msgid.link/20260127103151.21883-3-harry.yoo@oracle.com
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

authored by

Harry Yoo and committed by
Vlastimil Babka
2f35fee9 a77d6d33

+4 -3
+1
mm/slab.h
··· 411 411 unsigned int useroffset, unsigned int usersize); 412 412 413 413 int slab_unmergeable(struct kmem_cache *s); 414 + bool slab_args_unmergeable(struct kmem_cache_args *args, slab_flags_t flags); 414 415 415 416 slab_flags_t kmem_cache_flags(slab_flags_t flags, const char *name); 416 417
+1 -2
mm/slab_common.c
··· 174 174 return 0; 175 175 } 176 176 177 - static bool slab_args_unmergeable(struct kmem_cache_args *args, 178 - slab_flags_t flags) 177 + bool slab_args_unmergeable(struct kmem_cache_args *args, slab_flags_t flags) 179 178 { 180 179 if (slab_nomerge) 181 180 return true;
+2 -1
mm/slub.c
··· 8382 8382 */ 8383 8383 aligned_size = ALIGN(size, s->align); 8384 8384 #if defined(CONFIG_SLAB_OBJ_EXT) && defined(CONFIG_64BIT) 8385 - if (aligned_size - size >= sizeof(struct slabobj_ext)) 8385 + if (slab_args_unmergeable(args, s->flags) && 8386 + (aligned_size - size >= sizeof(struct slabobj_ext))) 8386 8387 s->flags |= SLAB_OBJ_EXT_IN_OBJ; 8387 8388 #endif 8388 8389 size = aligned_size;