tracing: Define kmem_trace_alloc_notrace unconditionally
Subsystems (2)
PATCH 1/2 tracing: Define kmem_trace_alloc_notrace unconditionally
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef CONFIG_KMEMTRACE, because a kmalloc() memory allocation may be traced by both trace_kmalloc() and trace_kmem_cache_alloc().
--- include/linux/slab_def.h | 24 ++---------------------- include/linux/slub_def.h | 27 +++------------------------ mm/slab.c | 12 ------------ mm/slub.c | 4 ---- 4 files changed, 5 insertions(+), 62 deletions(-)
include/linux/slab_def.h +2 -22
@@ -109,21 +109,12 @@ extern struct cache_sizes malloc_sizes[];void *kmem_cache_alloc (struct kmem_cache *,gfp_t );void *__kmalloc (size_t size,gfp_t flags); +void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags); -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags); -extern size_t slab_buffer_size (struct kmem_cache *cachep); -#else -static __always_inline void * -kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags) -{ -return kmem_cache_alloc (cachep, flags); -}static inline size_t slab_buffer_size (struct kmem_cache *cachep) { -return 0 ; +return cachep->buffer_size; } -#endif static __always_inline void *kmalloc(size_t size, gfp_t flags) {
@@ -165,20 +156,9 @@ found:#ifdef CONFIG_NUMA extern void *__kmalloc_node (size_t size,gfp_t flags,int node);extern void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); - -#ifdef CONFIG_KMEMTRACE extern void *kmem_cache_alloc_node_notrace (struct kmem_cache *cachep,gfp_t flags,int nodeid); -#else -static __always_inline void * -kmem_cache_alloc_node_notrace (struct kmem_cache *cachep, -gfp_t flags, -int nodeid) -{ -return kmem_cache_alloc_node (cachep, flags, nodeid); -} -#endif static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) {
include/linux/slub_def.h +3 -24
@@ -215,18 +215,9 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)#endif void *kmem_cache_alloc (struct kmem_cache *,gfp_t ); +void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags);void *__kmalloc (size_t size,gfp_t flags); -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags); -#else -static __always_inline void * -kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags) -{ -return kmem_cache_alloc (s, gfpflags); -} -#endif - static __always_inline void *kmalloc_large(size_t size, gfp_t flags) {unsigned int order =get_order (size);
@@ -265,20 +256,8 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)#ifdef CONFIG_NUMA void *__kmalloc_node (size_t size,gfp_t flags,int node);void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); - -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_node_notrace (struct kmem_cache *s, -gfp_t gfpflags, -int node); -#else -static __always_inline void * -kmem_cache_alloc_node_notrace (struct kmem_cache *s, -gfp_t gfpflags, -int node) -{ -return kmem_cache_alloc_node (s, gfpflags, node); -} -#endif +void *kmem_cache_alloc_node_notrace (struct kmem_cache *s,gfp_t gfpflags, +int node); static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) {
mm/slab.c +0 -12
@@ -490,14 +490,6 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp)#endif -#ifdef CONFIG_KMEMTRACE -size_t slab_buffer_size (struct kmem_cache *cachep) -{ -return cachep->buffer_size; -} -EXPORT_SYMBOL (slab_buffer_size); -#endif -/* * Do not go above this order unless 0 objects fit into the slab. */
@@ -3558,13 +3550,11 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) }EXPORT_SYMBOL (kmem_cache_alloc); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags) {return __cache_alloc (cachep, flags,__builtin_return_address (0 )); }EXPORT_SYMBOL (kmem_cache_alloc_notrace); -#endif /** * kmem_ptr_validate - check if an untrusted pointer might be a slab entry.
@@ -3621,7 +3611,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) }EXPORT_SYMBOL (kmem_cache_alloc_node); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_node_notrace (struct kmem_cache *cachep,gfp_t flags,int nodeid)
@@ -3630,7 +3619,6 @@ void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, __builtin_return_address(0)); }EXPORT_SYMBOL (kmem_cache_alloc_node_notrace); -#endif static __always_inline void *__do_kmalloc_node (size_t size,gfp_t flags,int node,void *caller)
mm/slub.c +0 -4
@@ -1754,13 +1754,11 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) }EXPORT_SYMBOL (kmem_cache_alloc); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags) {return slab_alloc (s, gfpflags,-1 , _RET_IP_); }EXPORT_SYMBOL (kmem_cache_alloc_notrace); -#endif #ifdef CONFIG_NUMA void *kmem_cache_alloc_node (struct kmem_cache *s,gfp_t gfpflags,int node)
@@ -1775,7 +1773,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)EXPORT_SYMBOL (kmem_cache_alloc_node);#endif -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_node_notrace (struct kmem_cache *s,gfp_t gfpflags,int node)
@@ -1783,7 +1780,6 @@ void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,return slab_alloc (s, gfpflags, node, _RET_IP_); }EXPORT_SYMBOL (kmem_cache_alloc_node_notrace); -#endif /* * Slow patch handling. This may still be called frequently since objects
Signature · 1 line
1.6.3
PATCH 2/2 tracing: Fix no callsite ifndef CONFIG_KMEMTRACE
For slab, if CONFIG_KMEMTRACE and CONFIG_DEBUG_SLAB are not set, __do_kmalloc() will not track callers:
# ./perf record -f -a -R -e kmem:kmalloc
^C
# ./perf trace
...
perf-2204 [000] 147.376774: kmalloc: call_site=c0529d2d ...
perf-2204 [000] 147.400997: kmalloc: call_site=c0529d2d ...
Xorg-1461 [001] 147.405413: kmalloc: call_site=0 ...
Xorg-1461 [001] 147.405609: kmalloc: call_site=0 ...
konsole-1776 [001] 147.405786: kmalloc: call_site=0 ...--- mm/slab.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
mm/slab.c +3 -3
@@ -3637,7 +3637,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)return ret; } -#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_KMEMTRACE ) +#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_TRACING )void *__kmalloc_node (size_t size,gfp_t flags,int node) { return __do_kmalloc_node(size, flags, node,
@@ -3657,7 +3657,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)return __do_kmalloc_node (size, flags, node,NULL ); }EXPORT_SYMBOL (__kmalloc_node); -#endif /* CONFIG_DEBUG_SLAB */ +#endif /* CONFIG_DEBUG_SLAB || CONFIG_TRACING */ #endif /* CONFIG_NUMA */ /**
@@ -3689,7 +3689,7 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, } -#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_KMEMTRACE ) +#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_TRACING )void *__kmalloc (size_t size,gfp_t flags) {return __do_kmalloc (size, flags,__builtin_return_address (0 ));
Signature · 1 line
1.6.3
Re: [PATCH 2/2] tracing: Fix no callsite ifndef CONFIG_KMEMTRACE
Quoted 13 lines · Li Zefan
For slab, if
CONFIG_KMEMTRACEandCONFIG_DEBUG_SLABare not set,__do_kmalloc()will not track callers:# ./perf record -f -a -R -e kmem:kmalloc ^C # ./perf trace ... perf-2204 [000] 147.376774: kmalloc: call_site=c0529d2d ... perf-2204 [000] 147.400997: kmalloc: call_site=c0529d2d ... Xorg-1461 [001] 147.405413: kmalloc: call_site=0 ... Xorg-1461 [001] 147.405609: kmalloc: call_site=0 ... konsole-1776 [001] 147.405786: kmalloc: call_site=0 ...
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>
Quoted 35 lines
--- mm/slab.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)mm/slab.c +3
-3@@ -3637,7 +3637,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)return ret; } -#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_KMEMTRACE ) +#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_TRACING )void *__kmalloc_node (size_t size,gfp_t flags,int node) { return __do_kmalloc_node(size, flags, node,@@ -3657,7 +3657,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)return __do_kmalloc_node (size, flags, node,NULL ); }EXPORT_SYMBOL (__kmalloc_node); -#endif /* CONFIG_DEBUG_SLAB */ +#endif /* CONFIG_DEBUG_SLAB || CONFIG_TRACING */ #endif /* CONFIG_NUMA */ /** @@ -3689,7 +3689,7 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, } -#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_KMEMTRACE ) +#if defined(CONFIG_DEBUG_SLAB ) || defined(CONFIG_TRACING )void *__kmalloc (size_t size,gfp_t flags) {return __do_kmalloc (size, flags,__builtin_return_address (0 ));
Quoted 6 lines · Li Zefan
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().Signed-off-by Li Zefan <[email protected]>
Did you check how much this will make kernel text bigger because of the inlining happening in kmem_cache_alloc_notrace()?
Pekka
Quoted 186 lines
--- include/linux/slab_def.h | 24 ++---------------------- include/linux/slub_def.h | 27 +++------------------------ mm/slab.c | 12 ------------ mm/slub.c | 4 ---- 4 files changed, 5 insertions(+), 62 deletions(-)include/linux/slab_def.h +2
-22@@ -109,21 +109,12 @@ extern struct cache_sizes malloc_sizes[];void *kmem_cache_alloc (struct kmem_cache *,gfp_t );void *__kmalloc (size_t size,gfp_t flags); +void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags); -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags); -extern size_t slab_buffer_size (struct kmem_cache *cachep); -#else -static __always_inline void * -kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags) -{ -return kmem_cache_alloc (cachep, flags); -}static inline size_t slab_buffer_size (struct kmem_cache *cachep) { -return 0 ; +return cachep->buffer_size; } -#endif static __always_inline void *kmalloc(size_t size, gfp_t flags) {@@ -165,20 +156,9 @@ found:#ifdef CONFIG_NUMA extern void *__kmalloc_node (size_t size,gfp_t flags,int node);extern void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); - -#ifdef CONFIG_KMEMTRACE extern void *kmem_cache_alloc_node_notrace (struct kmem_cache *cachep,gfp_t flags,int nodeid); -#else -static __always_inline void * -kmem_cache_alloc_node_notrace (struct kmem_cache *cachep, -gfp_t flags, -int nodeid) -{ -return kmem_cache_alloc_node (cachep, flags, nodeid); -} -#endif static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) {include/linux/slub_def.h +3
-24@@ -215,18 +215,9 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)#endif void *kmem_cache_alloc (struct kmem_cache *,gfp_t ); +void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags);void *__kmalloc (size_t size,gfp_t flags); -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags); -#else -static __always_inline void * -kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags) -{ -return kmem_cache_alloc (s, gfpflags); -} -#endif - static __always_inline void *kmalloc_large(size_t size, gfp_t flags) {unsigned int order =get_order (size);@@ -265,20 +256,8 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)#ifdef CONFIG_NUMA void *__kmalloc_node (size_t size,gfp_t flags,int node);void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); - -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_node_notrace (struct kmem_cache *s, -gfp_t gfpflags, -int node); -#else -static __always_inline void * -kmem_cache_alloc_node_notrace (struct kmem_cache *s, -gfp_t gfpflags, -int node) -{ -return kmem_cache_alloc_node (s, gfpflags, node); -} -#endif +void *kmem_cache_alloc_node_notrace (struct kmem_cache *s,gfp_t gfpflags, +int node); static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) {mm/slab.c +0
-12@@ -490,14 +490,6 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp)#endif -#ifdef CONFIG_KMEMTRACE -size_t slab_buffer_size (struct kmem_cache *cachep) -{ -return cachep->buffer_size; -} -EXPORT_SYMBOL (slab_buffer_size); -#endif -/* * Do not go above this order unless 0 objects fit into the slab. */ @@ -3558,13 +3550,11 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) }EXPORT_SYMBOL (kmem_cache_alloc); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags) {return __cache_alloc (cachep, flags,__builtin_return_address (0 )); }EXPORT_SYMBOL (kmem_cache_alloc_notrace); -#endif /** * kmem_ptr_validate - check if an untrusted pointer might be a slab entry. @@ -3621,7 +3611,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) }EXPORT_SYMBOL (kmem_cache_alloc_node); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_node_notrace (struct kmem_cache *cachep,gfp_t flags,int nodeid)@@ -3630,7 +3619,6 @@ void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, __builtin_return_address(0)); }EXPORT_SYMBOL (kmem_cache_alloc_node_notrace); -#endif static __always_inline void *__do_kmalloc_node (size_t size,gfp_t flags,int node,void *caller)mm/slub.c +0
-4@@ -1754,13 +1754,11 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) }EXPORT_SYMBOL (kmem_cache_alloc); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags) {return slab_alloc (s, gfpflags,-1 , _RET_IP_); }EXPORT_SYMBOL (kmem_cache_alloc_notrace); -#endif #ifdef CONFIG_NUMA void *kmem_cache_alloc_node (struct kmem_cache *s,gfp_t gfpflags,int node)@@ -1775,7 +1773,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)EXPORT_SYMBOL (kmem_cache_alloc_node);#endif -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_node_notrace (struct kmem_cache *s,gfp_t gfpflags,int node)@@ -1783,7 +1780,6 @@ void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,return slab_alloc (s, gfpflags, node, _RET_IP_); }EXPORT_SYMBOL (kmem_cache_alloc_node_notrace); -#endif /* * Slow patch handling. This may still be called frequently since objects
Quoted 9 lines · Pekka Enberg
Quoted 6 lines · Li Zefan
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().Signed-off-by Li Zefan <[email protected]>Did you check how much this will make kernel text bigger because of the inlining happening in
kmem_cache_alloc_notrace()?
Maybe use CONFIG_TRACING instead of CONFIG_KMEMTRACE here like in the other patch?
Quoted 206 lines
Quoted 204 lines
--- include/linux/slab_def.h | 24 ++---------------------- include/linux/slub_def.h | 27 +++------------------------ mm/slab.c | 12 ------------ mm/slub.c | 4 ---- 4 files changed, 5 insertions(+), 62 deletions(-)include/linux/slab_def.h +2
-11@@ -109,21 +109,12 @@ extern struct cache_sizes malloc_sizes[];void *kmem_cache_alloc (struct kmem_cache *,gfp_t );void *__kmalloc (size_t size,gfp_t flags); +void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags); -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_notrace (struct kmem_cache *cachep, gfp_t flags); -extern size_t slab_buffer_size (struct kmem_cache *cachep); -#else -static __always_inline void * -kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags) -{ -return kmem_cache_alloc (cachep, flags); -}static inline size_t slab_buffer_size (struct kmem_cache *cachep) { -return 0 ; +return cachep->buffer_size; } -#endif static __always_inline void *kmalloc(size_t size, gfp_t flags){
include/linux/slab_def.h +0
-11@@ -165,20 +156,9 @@ found:#ifdef CONFIG_NUMA extern void *__kmalloc_node (size_t size,gfp_t flags,int node);extern void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); - -#ifdef CONFIG_KMEMTRACE extern void *kmem_cache_alloc_node_notrace (struct kmem_cache *cachep,gfp_t flags,int nodeid); -#else -static __always_inline void * -kmem_cache_alloc_node_notrace (struct kmem_cache *cachep, -gfp_t flags, -int nodeid) -{ -return kmem_cache_alloc_node (cachep, flags, nodeid); -} -#endif static __always_inline void *kmalloc_node(size_t size, gfp_t flags,int node)
{include/linux/slub_def.h +1
-10@@ -215,18 +215,9 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)#endif void *kmem_cache_alloc (struct kmem_cache *,gfp_t ); +void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags);void *__kmalloc (size_t size,gfp_t flags); -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags); -#else -static __always_inline void * -kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags) -{ -return kmem_cache_alloc (s, gfpflags); -} -#endif - static __always_inline void *kmalloc_large(size_t size, gfp_t flags){ unsigned int order = get_order(size);include/linux/slub_def.h +2
-14@@ -265,20 +256,8 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)#ifdef CONFIG_NUMA void *__kmalloc_node (size_t size,gfp_t flags,int node);void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); - -#ifdef CONFIG_KMEMTRACE -extern void *kmem_cache_alloc_node_notrace (struct kmem_cache *s, -gfp_t gfpflags, -int node); -#else -static __always_inline void * -kmem_cache_alloc_node_notrace (struct kmem_cache *s, -gfp_t gfpflags, -int node) -{ -return kmem_cache_alloc_node (s, gfpflags, node); -} -#endif +void *kmem_cache_alloc_node_notrace (struct kmem_cache *s,gfp_t gfpflags, +int node);static
__always_inlinevoid *kmalloc_node(size_t size,gfp_tflags,
int node)
{mm/slab.c +0
-8@@ -490,14 +490,6 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp)#endif -#ifdef CONFIG_KMEMTRACE -size_t slab_buffer_size (struct kmem_cache *cachep) -{ -return cachep->buffer_size; -} -EXPORT_SYMBOL (slab_buffer_size); -#endif -/* * Do not go above this order unless 0 objects fit into the slab. */
mm/slab.c +0
-2@@ -3558,13 +3550,11 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) }EXPORT_SYMBOL (kmem_cache_alloc); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_notrace (struct kmem_cache *cachep,gfp_t flags) {return __cache_alloc (cachep, flags,__builtin_return_address (0 )); }EXPORT_SYMBOL (kmem_cache_alloc_notrace); -#endif /** *
kmem_ptr_validate- check if an untrusted pointer might be a slab
entry.mm/slab.c +0
-1@@ -3621,7 +3611,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) }EXPORT_SYMBOL (kmem_cache_alloc_node); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, gfp_t flags,int nodeid)
mm/slab.c +0
-1@@ -3630,7 +3619,6 @@ void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, __builtin_return_address(0)); }EXPORT_SYMBOL (kmem_cache_alloc_node_notrace); -#endif static __always_inline void *
__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)mm/slub.c +0
-2@@ -1754,13 +1754,11 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) }EXPORT_SYMBOL (kmem_cache_alloc); -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_notrace (struct kmem_cache *s,gfp_t gfpflags) {return slab_alloc (s, gfpflags,-1 , _RET_IP_); }EXPORT_SYMBOL (kmem_cache_alloc_notrace); -#endif #ifdef CONFIG_NUMA void *kmem_cache_alloc_node(struct
kmem_cache*s,gfp_tgfpflags, int
node)mm/slub.c +0
-1@@ -1775,7 +1773,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)EXPORT_SYMBOL (kmem_cache_alloc_node);#endif -#ifdef CONFIG_KMEMTRACE void *kmem_cache_alloc_node_notrace(struct kmem_cache *s, gfp_t gfpflags,int node)
mm/slub.c +0
-1@@ -1783,7 +1780,6 @@ void *kmem_cache_alloc_node_notrace(structkmem_cache *s, return slab_alloc(s, gfpflags, node, _RET_IP_); }EXPORT_SYMBOL (kmem_cache_alloc_node_notrace); -#endif /* * Slow patch handling. This may still be called frequently since
objects
Quoted 7 lines · Pekka Enberg
Quoted 6 lines · Pekka Enberg
Quoted 5 lines · Li Zefan
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>Did you check how much this will make kernel text bigger because of the inlining happening in
kmem_cache_alloc_notrace()?Maybe use
CONFIG_TRACINGinstead ofCONFIG_KMEMTRACEhere like in the other patch?
Wouldn't removing CONFIG_KMEMTRACE make the code cleaner? Anyway, if CONFIG_TRACING is not enabled, all the trace_xxx() will be turned into no-op.
Li Zefan kirjoitti:
Quoted 11 lines
Quoted 10 lines · Pekka Enberg
Quoted 9 lines · Pekka Enberg
Quoted 6 lines · Li Zefan
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().Signed-off-by Li Zefan <[email protected]>Did you check how much this will make kernel text bigger because of the inlining happening in
kmem_cache_alloc_notrace()?
Quoted 7 lines
Quoted 3 lines
Maybe use
CONFIG_TRACINGinstead ofCONFIG_KMEMTRACEhere like in the other patch?Wouldn't removing
CONFIG_KMEMTRACEmake the code cleaner? Anyway, ifCONFIG_TRACINGis not enabled, all thetrace_xxx()will be turned into no-op.
Again, I am talking about kernel text size increase in mm/slub.c.
Quoted 11 lines · Pekka Enberg
Quoted 6 lines · Li Zefan
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().Signed-off-by Li Zefan <[email protected]>Did you check how much this will make kernel text bigger because of the inlining happening in
kmem_cache_alloc_notrace()?
I'm not sure I understood what you meant, but I'm not inlining kmem_cache_alloc_notrace(), and instead I'm removing the inline version in !CONFIG_KMEMTRACE case.
Li Zefan kirjoitti:
Quoted 7 lines
Quoted 6 lines · Pekka Enberg
Quoted 5 lines · Li Zefan
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>Did you check how much this will make kernel text bigger because of the inlining happening in
kmem_cache_alloc_notrace()?I'm not sure I understood what you meant, but I'm not inlining
kmem_cache_alloc_notrace(), and instead I'm removing the inline version in !CONFIG_KMEMTRACE case.
In SLUB, slab_alloc() will be inlined to kmem_cache_alloc_notrace() increasing mm/slub.o size so we don't want to define kmem_cache_alloc_notrace() unconditionally.
Pekka
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Always define kmem_trace_alloc_{,node}_notrace(), otherwise perf-kmem will show wrong stats ifndef
CONFIG_KMEMTRACE, because akmalloc()memory allocation may be traced by bothtrace_kmalloc()andtrace_kmem_cache_alloc().Signed-off-by Li Zefan <[email protected]>Did you check how much this will make kernel text bigger because of the inlining happening in
kmem_cache_alloc_notrace()?
Quoted 8 lines
Quoted 3 lines
I'm not sure I understood what you meant, but I'm not inlining
kmem_cache_alloc_notrace(), and instead I'm removing the inline version in !CONFIG_KMEMTRACE case.In SLUB,
slab_alloc()will be inlined tokmem_cache_alloc_notrace()increasingmm/slub.osize so we don't want to definekmem_cache_alloc_notrace()unconditionally.
I got your point. I'll make a new patch based on your suggestion.
Thanks!