Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 19392
b: refs/heads/master
c: 7fd6b14
h: refs/heads/master
v: v3
  • Loading branch information
Pekka Enberg authored and Linus Torvalds committed Feb 1, 2006
1 parent ee56e90 commit 0300163
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b958f7d9f35bfb61625f201cd92a3fc39504af7a
refs/heads/master: 7fd6b1413082c303613fc137aca9a004740cacf0
7 changes: 7 additions & 0 deletions trunk/include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ struct cache_sizes {
kmem_cache_t *cs_dmacachep;
};
extern struct cache_sizes malloc_sizes[];

#ifndef CONFIG_DEBUG_SLAB
extern void *__kmalloc(size_t, gfp_t);
#else
extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
#define __kmalloc(size, flags) \
__kmalloc_track_caller(size, flags, __builtin_return_address(0))
#endif

static inline void *kmalloc(size_t size, gfp_t flags)
{
Expand Down
29 changes: 24 additions & 5 deletions trunk/mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,8 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
return objp;
}

static inline void *__cache_alloc(struct kmem_cache *cachep, gfp_t flags)
static __always_inline void *
__cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
{
unsigned long save_flags;
void *objp;
Expand All @@ -2698,7 +2699,7 @@ static inline void *__cache_alloc(struct kmem_cache *cachep, gfp_t flags)
objp = ____cache_alloc(cachep, flags);
local_irq_restore(save_flags);
objp = cache_alloc_debugcheck_after(cachep, flags, objp,
__builtin_return_address(0));
caller);
prefetchw(objp);
return objp;
}
Expand Down Expand Up @@ -2927,7 +2928,7 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp)
*/
void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
{
return __cache_alloc(cachep, flags);
return __cache_alloc(cachep, flags, __builtin_return_address(0));
}
EXPORT_SYMBOL(kmem_cache_alloc);

Expand Down Expand Up @@ -3041,7 +3042,8 @@ EXPORT_SYMBOL(kmalloc_node);
* platforms. For example, on i386, it means that the memory must come
* from the first 16MB.
*/
void *__kmalloc(size_t size, gfp_t flags)
static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
void *caller)
{
struct kmem_cache *cachep;

Expand All @@ -3053,10 +3055,27 @@ void *__kmalloc(size_t size, gfp_t flags)
cachep = __find_general_cachep(size, flags);
if (unlikely(cachep == NULL))
return NULL;
return __cache_alloc(cachep, flags);
return __cache_alloc(cachep, flags, caller);
}

#ifndef CONFIG_DEBUG_SLAB

void *__kmalloc(size_t size, gfp_t flags)
{
return __do_kmalloc(size, flags, NULL);
}
EXPORT_SYMBOL(__kmalloc);

#else

void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller)
{
return __do_kmalloc(size, flags, caller);
}
EXPORT_SYMBOL(__kmalloc_track_caller);

#endif

#ifdef CONFIG_SMP
/**
* __alloc_percpu - allocate one copy of the object for every present
Expand Down

0 comments on commit 0300163

Please sign in to comment.