[PATCH v2] mm, slub: Restore initial kmem_cache flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The routine that applies debug flags to the kmem_cache slabs
inadvertantly prevents non-debug flags from being applied to
those same objects. That is, if slub_debug=<flag>,<slab> is
specified, non-debugged slabs will end up having flags of zero,
and the slabs may be unusable.

Fix this by including the input flags for non-matching slabs
with the contents of slub_debug, so that the caches are
created as expected alongside any debugging options that may
be requested. With this, we can remove the check for a NULL
slub_debug_string, since it's covered by the loop itself.

Fixes: e17f1dfba37b ("mm, slub: extend slub_debug syntax for multiple blocks")
Signed-off-by: Eric Farman <farman@xxxxxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
---
 v2: OR return values per Vlastimil, applied his Ack
 v1: https://lore.kernel.org/linux-mm/20200930112612.76109-1-farman@xxxxxxxxxxxxx/T/#t
---
 mm/slub.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index d4177aecedf6..6d3574013b2f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1413,10 +1413,6 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
 	char *next_block;
 	slab_flags_t block_flags;
 
-	/* If slub_debug = 0, it folds into the if conditional. */
-	if (!slub_debug_string)
-		return flags | slub_debug;
-
 	len = strlen(name);
 	next_block = slub_debug_string;
 	/* Go through all blocks of debug options, see if any matches our slab's name */
@@ -1450,7 +1446,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
 		}
 	}
 
-	return slub_debug;
+	return flags | slub_debug;
 }
 #else /* !CONFIG_SLUB_DEBUG */
 static inline void setup_object_debug(struct kmem_cache *s,
-- 
2.17.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux