Skip to content

Commit c45248d

Browse files
hygonitehcaster
authored andcommitted
mm/slab_common: cleanup kmalloc_track_caller()
Make kmalloc_track_caller() wrapper of kmalloc_node_track_caller(). Signed-off-by: Hyeonggon Yoo <[email protected]> Reviewed-by: Vlastimil Babka <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent f78a03f commit c45248d

File tree

4 files changed

+8
-43
lines changed

4 files changed

+8
-43
lines changed

include/linux/slab.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@ static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flag
651651
return kmalloc_array(n, size, flags | __GFP_ZERO);
652652
}
653653

654+
void *__kmalloc_node_track_caller(size_t size, gfp_t flags, int node,
655+
unsigned long caller) __alloc_size(1);
656+
#define kmalloc_node_track_caller(size, flags, node) \
657+
__kmalloc_node_track_caller(size, flags, node, \
658+
_RET_IP_)
659+
654660
/*
655661
* kmalloc_track_caller is a special version of kmalloc that records the
656662
* calling function of the routine calling it for slab leak tracking instead
@@ -659,9 +665,9 @@ static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flag
659665
* allocator where we care about the real place the memory allocation
660666
* request comes from.
661667
*/
662-
extern void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller);
663668
#define kmalloc_track_caller(size, flags) \
664-
__kmalloc_track_caller(size, flags, _RET_IP_)
669+
__kmalloc_node_track_caller(size, flags, \
670+
NUMA_NO_NODE, _RET_IP_)
665671

666672
static inline __alloc_size(1, 2) void *kmalloc_array_node(size_t n, size_t size, gfp_t flags,
667673
int node)
@@ -680,13 +686,6 @@ static inline __alloc_size(1, 2) void *kcalloc_node(size_t n, size_t size, gfp_t
680686
return kmalloc_array_node(n, size, flags | __GFP_ZERO, node);
681687
}
682688

683-
684-
extern void *__kmalloc_node_track_caller(size_t size, gfp_t flags, int node,
685-
unsigned long caller) __alloc_size(1);
686-
#define kmalloc_node_track_caller(size, flags, node) \
687-
__kmalloc_node_track_caller(size, flags, node, \
688-
_RET_IP_)
689-
690689
/*
691690
* Shortcuts
692691
*/

mm/slab.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,12 +3665,6 @@ void *__kmalloc(size_t size, gfp_t flags)
36653665
}
36663666
EXPORT_SYMBOL(__kmalloc);
36673667

3668-
void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller)
3669-
{
3670-
return __do_kmalloc(size, flags, caller);
3671-
}
3672-
EXPORT_SYMBOL(__kmalloc_track_caller);
3673-
36743668
/**
36753669
* kmem_cache_free - Deallocate an object
36763670
* @cachep: The cache the allocation was from.

mm/slob.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,6 @@ void *__kmalloc(size_t size, gfp_t gfp)
530530
}
531531
EXPORT_SYMBOL(__kmalloc);
532532

533-
void *__kmalloc_track_caller(size_t size, gfp_t gfp, unsigned long caller)
534-
{
535-
return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, caller);
536-
}
537-
EXPORT_SYMBOL(__kmalloc_track_caller);
538-
539533
void *__kmalloc_node_track_caller(size_t size, gfp_t gfp,
540534
int node, unsigned long caller)
541535
{

mm/slub.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4904,28 +4904,6 @@ int __kmem_cache_create(struct kmem_cache *s, slab_flags_t flags)
49044904
return 0;
49054905
}
49064906

4907-
void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
4908-
{
4909-
struct kmem_cache *s;
4910-
void *ret;
4911-
4912-
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
4913-
return kmalloc_large(size, gfpflags);
4914-
4915-
s = kmalloc_slab(size, gfpflags);
4916-
4917-
if (unlikely(ZERO_OR_NULL_PTR(s)))
4918-
return s;
4919-
4920-
ret = slab_alloc(s, NULL, gfpflags, caller, size);
4921-
4922-
/* Honor the call site pointer we received. */
4923-
trace_kmalloc(caller, ret, s, size, s->size, gfpflags);
4924-
4925-
return ret;
4926-
}
4927-
EXPORT_SYMBOL(__kmalloc_track_caller);
4928-
49294907
void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
49304908
int node, unsigned long caller)
49314909
{

0 commit comments

Comments
 (0)