Commit 3de47213 authored by David Rientjes's avatar David Rientjes Committed by Pekka Enberg
Browse files

slub: use size and objsize orders to disable debug flags

This patch moves the masking of debugging flags which increase a cache's
min order due to metadata when `slub_debug=O' is used from
kmem_cache_flags() to kmem_cache_open().

Instead of defining the maximum metadata size increase in a preprocessor
macro, this approach uses the cache's ->size and ->objsize members to
determine if the min order increased due to debugging options.  If so,
the flags specified in the more appropriately named DEBUG_METADATA_FLAGS
are masked off.

This approach was suggested by Christoph Lameter

Cc: Christoph Lameter <>
Signed-off-by: default avatarDavid Rientjes <>
Signed-off-by: default avatarPekka Enberg <>
parent fa5ec8a1
......@@ -142,11 +142,11 @@
* Debugging flags that require metadata to be stored in the slab, up to
* DEBUG_SIZE in size.
* Debugging flags that require metadata to be stored in the slab. These get
* disabled when slub_debug=O is used and a cache's min order increases with
* metadata.
#define DEBUG_SIZE (3 * sizeof(void *) + 2 * sizeof(struct track))
* Set of flags that will prevent slab merging
......@@ -1040,27 +1040,13 @@ static unsigned long kmem_cache_flags(unsigned long objsize,
unsigned long flags, const char *name,
void (*ctor)(void *))
int debug_flags = slub_debug;
* Enable debugging if selected on the kernel commandline.
if (debug_flags) {
if (slub_debug_slabs &&
strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)))
goto out;
* Disable debugging that increases slab size if the minimum
* slab order would have increased as a result.
if (disable_higher_order_debug &&
get_order(objsize + DEBUG_SIZE) > get_order(objsize))
debug_flags &= ~DEBUG_SIZE_FLAGS;
if (slub_debug && (!slub_debug_slabs ||
!strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))))
flags |= slub_debug;
flags |= debug_flags;
return flags;
......@@ -2488,6 +2474,18 @@ static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
if (!calculate_sizes(s, -1))
goto error;
if (disable_higher_order_debug) {
* Disable debugging flags that store metadata if the min slab
* order increased.
if (get_order(s->size) > get_order(s->objsize)) {
s->offset = 0;
if (!calculate_sizes(s, -1))
goto error;
* The larger the object size is, the more pages we want on the partial
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