Skip to content

Commit 9ac38e3

Browse files
Grygorii Maistrenkogregkh
authored andcommitted
slub: do not merge cache if slub_debug contains a never-merge flag
[ Upstream commit c6e28895a4372992961888ffaadc9efc643b5bfe ] In case CONFIG_SLUB_DEBUG_ON=n, find_mergeable() gets debug features from commandline but never checks if there are features from the SLAB_NEVER_MERGE set. 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. Link: http://lkml.kernel.org/r/20170101124451.GA4740@lp-laptop-d Signed-off-by: Grygorii Maistrenko <grygoriimkd@gmail.com> Reviewed-by: Pekka Enberg <penberg@kernel.org> Acked-by: David Rientjes <rientjes@google.com> Acked-by: Christoph Lameter <cl@linux.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 315689d commit 9ac38e3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mm/slab_common.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ struct kmem_cache *find_mergeable(size_t size, size_t align,
250250
{
251251
struct kmem_cache *s;
252252

253-
if (slab_nomerge || (flags & SLAB_NEVER_MERGE))
253+
if (slab_nomerge)
254254
return NULL;
255255

256256
if (ctor)
@@ -261,6 +261,9 @@ struct kmem_cache *find_mergeable(size_t size, size_t align,
261261
size = ALIGN(size, align);
262262
flags = kmem_cache_flags(size, flags, name, NULL);
263263

264+
if (flags & SLAB_NEVER_MERGE)
265+
return NULL;
266+
264267
list_for_each_entry_reverse(s, &slab_caches, list) {
265268
if (slab_unmergeable(s))
266269
continue;

0 commit comments

Comments
 (0)