From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: cl@linux-foundation.org, penberg@cs.helsinki.fi, mpm@selenic.com,
vegard.nossum@gmail.com, dmonakhov@openvz.org,
catalin.marinas@arm.com, rientjes@google.com, dfeng@redhat.com
Cc: linux-mm@kvack.org
Subject: [RFC][PATCH] slab: fix caller tracking on CONFIG_OPTIMIZE_INLINING.
Date: Sat, 24 Sep 2011 12:08:55 +0900 [thread overview]
Message-ID: <201109241208.IEH26037.FtSVLJOOQHMFFO@I-love.SAKURA.ne.jp> (raw)
If CONFIG_OPTIMIZE_INLINING=y, /proc/slab_allocators shows entries like
size-512: 5 kzalloc+0xb/0x10
size-256: 31 kzalloc+0xb/0x10
which are useless for debugging.
Use "__always_inline" rather than "inline" in order to make
/proc/slab_allocators show caller of kzalloc() if caller tracking is enabled.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
----------
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 573c809..2b745c0 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -188,6 +188,18 @@ size_t ksize(const void *);
#else
#include <linux/slab_def.h>
#endif
+/*
+ * /proc/slab_allocator needs _RET_IP_ value. If CONFIG_OPTIMIZE_INLINING=y,
+ * use of "inline" causes compilers to pass address of kzalloc() etc. rather
+ * than address of caller. Thus, use "__always_inline" if _RET_IP_ value is
+ * needed.
+ */
+#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
+ (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
+#define slabtrace_inline __always_inline
+#else
+#define slabtrace_inline inline
+#endif
/**
* kcalloc - allocate memory for an array. The memory is set to zero.
@@ -240,7 +252,7 @@ size_t ksize(const void *);
* for general use, and so are not documented here. For a full list of
* potential flags, always refer to linux/gfp.h.
*/
-static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
+static slabtrace_inline void *kcalloc(size_t n, size_t size, gfp_t flags)
{
if (size != 0 && n > ULONG_MAX / size)
return NULL;
@@ -258,19 +270,19 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
* if available. Equivalent to kmalloc() in the non-NUMA single-node
* case.
*/
-static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
+static slabtrace_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
{
return kmalloc(size, flags);
}
-static inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
+static slabtrace_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
{
return __kmalloc(size, flags);
}
void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
-static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
+static slabtrace_inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
gfp_t flags, int node)
{
return kmem_cache_alloc(cachep, flags);
@@ -325,7 +337,7 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
/*
* Shortcuts
*/
-static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
+static slabtrace_inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
{
return kmem_cache_alloc(k, flags | __GFP_ZERO);
}
@@ -335,7 +347,7 @@ static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
* @size: how many bytes of memory are required.
* @flags: the type of memory to allocate (see kmalloc).
*/
-static inline void *kzalloc(size_t size, gfp_t flags)
+static slabtrace_inline void *kzalloc(size_t size, gfp_t flags)
{
return kmalloc(size, flags | __GFP_ZERO);
}
@@ -346,7 +358,7 @@ static inline void *kzalloc(size_t size, gfp_t flags)
* @flags: the type of memory to allocate (see kmalloc).
* @node: memory node from which to allocate
*/
-static inline void *kzalloc_node(size_t size, gfp_t flags, int node)
+static slabtrace_inline void *kzalloc_node(size_t size, gfp_t flags, int node)
{
return kmalloc_node(size, flags | __GFP_ZERO, node);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2011-09-24 3:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-24 3:08 Tetsuo Handa [this message]
2011-09-24 23:00 ` David Rientjes
2011-09-25 5:21 ` [RFC][PATCH] slab: fix caller tracking onCONFIG_OPTIMIZE_INLINING Tetsuo Handa
2011-09-27 1:22 ` David Rientjes
2011-09-26 6:17 ` [RFC][PATCH] slab: fix caller tracking on CONFIG_OPTIMIZE_INLINING Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109241208.IEH26037.FtSVLJOOQHMFFO@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=catalin.marinas@arm.com \
--cc=cl@linux-foundation.org \
--cc=dfeng@redhat.com \
--cc=dmonakhov@openvz.org \
--cc=linux-mm@kvack.org \
--cc=mpm@selenic.com \
--cc=penberg@cs.helsinki.fi \
--cc=rientjes@google.com \
--cc=vegard.nossum@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox