Skip to content

Commit

Permalink
mm/slub: Add debugging to verify correct cache use on kmem_cache_free()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Christoph Lameter <[email protected]>
[ [email protected]: Use pr_err() ]
Signed-off-by: Pekka Enberg <[email protected]>
  • Loading branch information
Christoph Lameter authored and penberg committed Sep 5, 2012
1 parent e21827a commit 7957610
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7957610

Please sign in to comment.