Commit c6e28895 authored by Grygorii Maistrenko's avatar Grygorii Maistrenko Committed by Linus Torvalds
Browse files

slub: do not merge cache if slub_debug contains a never-merge flag

In case CONFIG_SLUB_DEBUG_ON=n, find_mergeable() gets debug features from
commandline but never checks if there are features from the

As a result selected by slub_debug caches are always mergeable if they
have been created without a custom constructor set or without one of the
SLAB_* debug features on.

This moves the SLAB_NEVER_MERGE check below the flags update from
commandline to make sure it won't merge the slab cache if one of the debug
features is on.


Signed-off-by: default avatarGrygorii Maistrenko <>
Reviewed-by: default avatarPekka Enberg <>
Acked-by: default avatarDavid Rientjes <>
Acked-by: default avatarChristoph Lameter <>
Cc: Joonsoo Kim <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 8dcde9de
......@@ -255,7 +255,7 @@ struct kmem_cache *find_mergeable(size_t size, size_t align,
struct kmem_cache *s;
if (slab_nomerge || (flags & SLAB_NEVER_MERGE))
if (slab_nomerge)
return NULL;
if (ctor)
......@@ -266,6 +266,9 @@ struct kmem_cache *find_mergeable(size_t size, size_t align,
size = ALIGN(size, align);
flags = kmem_cache_flags(size, flags, name, NULL);
if (flags & SLAB_NEVER_MERGE)
return NULL;
list_for_each_entry_reverse(s, &slab_caches, list) {
if (slab_unmergeable(s))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment