aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2009-07-27 21:30:35 -0400
committerPekka Enberg <penberg@cs.helsinki.fi>2009-07-28 03:53:09 -0400
commit3de472138a138008b534d9587593ba83390e330a (patch)
tree2f31ccb13c90dff68d8fd108575caa534c6c622d /mm/slub.c
parentfa5ec8a1f66f3c2a3af723abcf8085509c9ee682 (diff)
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 <cl@linux-foundation.org>. Cc: Christoph Lameter <cl@linux-foundation.org> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 466089cd5deb..a465c0a09fb5 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -142,11 +142,11 @@
142 SLAB_POISON | SLAB_STORE_USER) 142 SLAB_POISON | SLAB_STORE_USER)
143 143
144/* 144/*
145 * Debugging flags that require metadata to be stored in the slab, up to 145 * Debugging flags that require metadata to be stored in the slab. These get
146 * DEBUG_SIZE in size. 146 * disabled when slub_debug=O is used and a cache's min order increases with
147 * metadata.
147 */ 148 */
148#define DEBUG_SIZE_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER) 149#define DEBUG_METADATA_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
149#define DEBUG_SIZE (3 * sizeof(void *) + 2 * sizeof(struct track))
150 150
151/* 151/*
152 * Set of flags that will prevent slab merging 152 * Set of flags that will prevent slab merging
@@ -1040,27 +1040,13 @@ static unsigned long kmem_cache_flags(unsigned long objsize,
1040 unsigned long flags, const char *name, 1040 unsigned long flags, const char *name,
1041 void (*ctor)(void *)) 1041 void (*ctor)(void *))
1042{ 1042{
1043 int debug_flags = slub_debug;
1044
1045 /* 1043 /*
1046 * Enable debugging if selected on the kernel commandline. 1044 * Enable debugging if selected on the kernel commandline.
1047 */ 1045 */
1048 if (debug_flags) { 1046 if (slub_debug && (!slub_debug_slabs ||
1049 if (slub_debug_slabs && 1047 !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))))
1050 strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))) 1048 flags |= slub_debug;
1051 goto out;
1052
1053 /*
1054 * Disable debugging that increases slab size if the minimum
1055 * slab order would have increased as a result.
1056 */
1057 if (disable_higher_order_debug &&
1058 get_order(objsize + DEBUG_SIZE) > get_order(objsize))
1059 debug_flags &= ~DEBUG_SIZE_FLAGS;
1060 1049
1061 flags |= debug_flags;
1062 }
1063out:
1064 return flags; 1050 return flags;
1065} 1051}
1066#else 1052#else
@@ -2488,6 +2474,18 @@ static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
2488 2474
2489 if (!calculate_sizes(s, -1)) 2475 if (!calculate_sizes(s, -1))
2490 goto error; 2476 goto error;
2477 if (disable_higher_order_debug) {
2478 /*
2479 * Disable debugging flags that store metadata if the min slab
2480 * order increased.
2481 */
2482 if (get_order(s->size) > get_order(s->objsize)) {
2483 s->flags &= ~DEBUG_METADATA_FLAGS;
2484 s->offset = 0;
2485 if (!calculate_sizes(s, -1))
2486 goto error;
2487 }
2488 }
2491 2489
2492 /* 2490 /*
2493 * The larger the object size is, the more pages we want on the partial 2491 * The larger the object size is, the more pages we want on the partial