slab: add hooks for kmemcheck
PATCH 12/13 slab: add hooks for kmemcheck
Quoted 1 line
From
4676a60f81caf87e9c0e0e71af49bdaf83fbb567Mon Sep 17 00:00:00 2001
From: Pekka Enberg <[email protected]>
Date: Fri, 9 May 2008 20:35:53 +0200
Subject: [PATCH 12/13] slab: add hooks for kmemcheck
We now have SLAB support for kmemcheck! This means that it doesn't matter whether one chooses SLAB or SLUB, or indeed whether Linus chooses to chuck SLAB or SLUB.. ;-)
Signed-off-by Vegard Nossum <[email protected]>
--- mm/slab.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-)
mm/slab.c +18 -2
@@ -111,6 +111,7 @@#include <linux/rtmutex.h> #include <linux/reciprocal_div.h> #include <linux/debugobjects.h> +#include <linux/kmemcheck.h> #include <asm/cacheflush.h> #include <asm/tlbflush.h>
@@ -176,13 +177,13 @@ SLAB_STORE_USER | \ SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \ - SLAB_DEBUG_OBJECTS) + SLAB_DEBUG_OBJECTS | SLAB_NOTRACK)#else # define CREATE_MASK (SLAB_HWCACHE_ALIGN | \ SLAB_CACHE_DMA | \ SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \ - SLAB_DEBUG_OBJECTS) + SLAB_DEBUG_OBJECTS | SLAB_NOTRACK)#endif /*
@@ -1611,6 +1612,10 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) NR_SLAB_UNRECLAIMABLE, nr_pages);for (i =0 ; i < nr_pages; i++)__SetPageSlab (page + i); + +if (kmemcheck_enabled && !(cachep->flags &SLAB_NOTRACK )) +kmemcheck_alloc_shadow (cachep, flags, nodeid, page, cachep->gfporder); +return page_address (page); }
@@ -1623,6 +1628,9 @@ static void kmem_freepages(struct kmem_cache *cachep, void *addr)struct page *page =virt_to_page (addr);const unsigned long nr_freed = i; +if (kmemcheck_page_is_tracked (page)) +kmemcheck_free_shadow (cachep, page, cachep->gfporder); +if (cachep->flags &SLAB_RECLAIM_ACCOUNT )sub_zone_page_state (page_zone (page),NR_SLAB_RECLAIMABLE , nr_freed);
@@ -3340,6 +3348,9 @@ __cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,local_irq_restore (save_flags); ptr =cache_alloc_debugcheck_after (cachep, flags, ptr, caller); +if (likely (ptr)) +kmemcheck_slab_alloc (cachep, flags, ptr,obj_size (cachep)); +if (unlikely ((flags & __GFP_ZERO) && ptr))memset (ptr,0 ,obj_size (cachep));
@@ -3394,6 +3405,9 @@ __cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller) objp =cache_alloc_debugcheck_after (cachep, flags, objp, caller);prefetchw (objp); +if (likely (objp)) +kmemcheck_slab_alloc (cachep, flags, objp,obj_size (cachep)); +if (unlikely ((flags & __GFP_ZERO) && objp))memset (objp,0 ,obj_size (cachep));
@@ -3509,6 +3523,8 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp)check_irq_off (); objp =cache_free_debugcheck (cachep, objp,__builtin_return_address (0 )); +kmemcheck_slab_free (cachep, objp,obj_size (cachep)); +/* * Skip calling cache_free_alien() when the platform is not numa. * This will avoid cache misses that happen while accessing slabp (which
Signature · 1 line
1.5.5.1