summaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorChristoph Lameter2012-09-05 01:06:14 +0200
committerPekka Enberg2012-09-05 11:00:35 +0200
commit79576102afc24fcc6627d7a15691e432d9a2eacb (patch)
treedf44371aad955bc889f8d72b32b754ac1592ed60 /mm/slub.c
parentmm: Use __do_krealloc to do the krealloc job (diff)
downloadkernel-qcow2-linux-79576102afc24fcc6627d7a15691e432d9a2eacb.tar.gz
kernel-qcow2-linux-79576102afc24fcc6627d7a15691e432d9a2eacb.tar.xz
kernel-qcow2-linux-79576102afc24fcc6627d7a15691e432d9a2eacb.zip
mm/slub: Add debugging to verify correct cache use on kmem_cache_free()
Add additional debugging to check that the objects is actually from the cache the caller claims. Doing so currently trips up some other debugging code. It takes a lot to infer from that what was happening. Reviewed-by: Glauber Costa <glommer@parallels.com> Signed-off-by: Christoph Lameter <cl@linux.com> [ penberg@kernel.org: Use pr_err() ] Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c
index c67bd0a4a952..990592174340 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2614,6 +2614,13 @@ void kmem_cache_free(struct kmem_cache *s, void *x)
page = virt_to_head_page(x);
+ if (kmem_cache_debug(s) && page->slab != s) {
+ pr_err("kmem_cache_free: Wrong slab cache. %s but object"
+ " is from %s\n", page->slab->name, s->name);
+ WARN_ON_ONCE(1);
+ return;
+ }
+
slab_free(s, page, x, _RET_IP_);
trace_kmem_cache_free(_RET_IP_, x);