From: Christoph Lameter Date: Tue, 4 Sep 2012 23:06:14 +0000 (+0000) Subject: mm/slub: Add debugging to verify correct cache use on kmem_cache_free() X-Git-Tag: upstream/snapshot3+hdmi~6454^2~2^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79576102afc24fcc6627d7a15691e432d9a2eacb;hp=e21827aadd77e33833eeb393de2e8675e9b399e2;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Signed-off-by: Christoph Lameter [ penberg@kernel.org: Use pr_err() ] Signed-off-by: Pekka Enberg --- diff --git a/mm/slub.c b/mm/slub.c index c67bd0a..9905921 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);