Skip to content

Commit

Permalink
SLAB: Record actual last user of freed objects.
Browse files Browse the repository at this point in the history
Currently, when using CONFIG_DEBUG_SLAB, we put in kfree() or
kmem_cache_free() as the last user of free objects, which is not
very useful, so change it to the caller of those functions instead.

Acked-by: David Rientjes <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Signed-off-by: Suleiman Souhlal <[email protected]>
Signed-off-by: Pekka Enberg <[email protected]>
  • Loading branch information
repppie authored and penberg committed Jun 3, 2011
1 parent d4d84fe commit a947eb9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -3604,13 +3604,14 @@ static void cache_flusharray(struct kmem_cache *cachep, struct array_cache *ac)
* Release an obj back to its cache. If the obj has a constructed state, it must
* be in this state _before_ it is released. Called with disabled ints.
*/
static inline void __cache_free(struct kmem_cache *cachep, void *objp)
static inline void __cache_free(struct kmem_cache *cachep, void *objp,
void *caller)
{
struct array_cache *ac = cpu_cache_get(cachep);

check_irq_off();
kmemleak_free_recursive(objp, cachep->flags);
objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
objp = cache_free_debugcheck(cachep, objp, caller);

kmemcheck_slab_free(cachep, objp, obj_size(cachep));

Expand Down Expand Up @@ -3801,7 +3802,7 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
debug_check_no_locks_freed(objp, obj_size(cachep));
if (!(cachep->flags & SLAB_DEBUG_OBJECTS))
debug_check_no_obj_freed(objp, obj_size(cachep));
__cache_free(cachep, objp);
__cache_free(cachep, objp, __builtin_return_address(0));
local_irq_restore(flags);

trace_kmem_cache_free(_RET_IP_, objp);
Expand Down Expand Up @@ -3831,7 +3832,7 @@ void kfree(const void *objp)
c = virt_to_cache(objp);
debug_check_no_locks_freed(objp, obj_size(c));
debug_check_no_obj_freed(objp, obj_size(c));
__cache_free(c, (void *)objp);
__cache_free(c, (void *)objp, __builtin_return_address(0));
local_irq_restore(flags);
}
EXPORT_SYMBOL(kfree);
Expand Down

0 comments on commit a947eb9

Please sign in to comment.