For better capturing the caller details for allocation wrappers, introduce kmem_buckets_alloc_track_caller() by plumbing the buckets into the existing *_track_caller() interfaces. Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx> --- Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx> Cc: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx> Cc: linux-mm@xxxxxxxxx --- include/linux/slab.h | 11 +++++++---- mm/slub.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 08d248f9a1ba..7d84f875dcf4 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -606,6 +606,9 @@ void *kmem_buckets_alloc(kmem_buckets *b, size_t size, gfp_t flags) return __kmalloc_node(b, size, flags, NUMA_NO_NODE); } +#define kmem_buckets_alloc_track_caller(b, size, flags) \ + __kmalloc_node_track_caller(b, size, flags, NUMA_NO_NODE, _RET_IP_) + static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node) { if (__builtin_constant_p(size) && size) { @@ -670,10 +673,10 @@ static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flag return kmalloc_array(n, size, flags | __GFP_ZERO); } -void *__kmalloc_node_track_caller(size_t size, gfp_t flags, int node, - unsigned long caller) __alloc_size(1); +void *__kmalloc_node_track_caller(kmem_buckets *b, size_t size, gfp_t flags, int node, + unsigned long caller) __alloc_size(2); #define kmalloc_node_track_caller(size, flags, node) \ - __kmalloc_node_track_caller(size, flags, node, \ + __kmalloc_node_track_caller(NULL, size, flags, node, \ _RET_IP_) /* @@ -685,7 +688,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t flags, int node, * request comes from. */ #define kmalloc_track_caller(size, flags) \ - __kmalloc_node_track_caller(size, flags, \ + __kmalloc_node_track_caller(NULL, size, flags, \ NUMA_NO_NODE, _RET_IP_) static inline __alloc_size(1, 2) void *kmalloc_array_node(size_t n, size_t size, gfp_t flags, diff --git a/mm/slub.c b/mm/slub.c index 71220b4b1f79..ae54ec452a11 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3995,10 +3995,10 @@ void *__kmalloc(size_t size, gfp_t flags) } EXPORT_SYMBOL(__kmalloc); -void *__kmalloc_node_track_caller(size_t size, gfp_t flags, +void *__kmalloc_node_track_caller(kmem_buckets *b, size_t size, gfp_t flags, int node, unsigned long caller) { - return __do_kmalloc_node(NULL, size, flags, node, caller); + return __do_kmalloc_node(b, size, flags, node, caller); } EXPORT_SYMBOL(__kmalloc_node_track_caller); -- 2.34.1