2010-04-08 10:12:44

by Xiaotian Feng

[permalink] [raw]
Subject: [PATCH] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

In slab, all __xxx_track_caller is defined on CONFIG_DEBUG_SLAB || CONFIG_TRACING,
thus caller tracking function should be worked for CONFIG_TRACING. But if
CONFIG_DEBUG_SLAB is not set, include/linux/slab.h will define xxx_track_caller to
__xxx() without consideration of CONFIG_TRACING. This will break the caller tracking
behaviour then.

Signed-off-by: Xiaotian Feng <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Matt Mackall <[email protected]>
Cc: Vegard Nossum <[email protected]>
Cc: Dmitry Monakhov <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: David Rientjes <[email protected]>
---
include/linux/slab.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 4884462..1a0625c 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -267,7 +267,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
* allocator where we care about the real place the memory allocation
* request comes from.
*/
-#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
+#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || defined(CONFIG_TRACING)
extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
#define kmalloc_track_caller(size, flags) \
__kmalloc_track_caller(size, flags, _RET_IP_)
@@ -285,7 +285,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
* standard allocator where we care about the real place the memory
* allocation request comes from.
*/
-#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
+#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || defined(CONFIG_TRACING)
extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
#define kmalloc_node_track_caller(size, flags, node) \
__kmalloc_node_track_caller(size, flags, node, \
--
1.7.0.1


2010-04-08 19:12:18

by David Rientjes

[permalink] [raw]
Subject: Re: [PATCH] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

On Thu, 8 Apr 2010, Xiaotian Feng wrote:

> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 4884462..1a0625c 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -267,7 +267,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
> * allocator where we care about the real place the memory allocation
> * request comes from.
> */
> -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
> +#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || defined(CONFIG_TRACING)
> extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
> #define kmalloc_track_caller(size, flags) \
> __kmalloc_track_caller(size, flags, _RET_IP_)
> @@ -285,7 +285,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
> * standard allocator where we care about the real place the memory
> * allocation request comes from.
> */
> -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
> +#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || defined(CONFIG_TRACING)
> extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
> #define kmalloc_node_track_caller(size, flags, node) \
> __kmalloc_node_track_caller(size, flags, node, \

This doesn't work if the underlying slab allocator doesn't define
__kmalloc_node_track_caller() regardless of whether CONFIG_TRACING is
enabled or not. SLOB, for example, never defines it, and that's why the
conditional exists in the way it currently does.

This is your patch with CONFIG_EMBEDDED && CONFIG_SLOB:

mm/built-in.o: In function `__krealloc':
(.text+0x1283c): undefined reference to `__kmalloc_track_caller'
mm/built-in.o: In function `kmemdup':
(.text+0x128b4): undefined reference to `__kmalloc_track_caller'
mm/built-in.o: In function `kstrndup':
(.text+0x128fc): undefined reference to `__kmalloc_track_caller'
mm/built-in.o: In function `kstrdup':
(.text+0x12943): undefined reference to `__kmalloc_track_caller'
mm/built-in.o: In function `memdup_user':
(.text+0x129f7): undefined reference to `__kmalloc_track_caller'
drivers/built-in.o:(.text+0xc48a4): more undefined references to `__kmalloc_track_caller' follow
net/built-in.o: In function `__alloc_skb':
(.text+0x8dc6): undefined reference to `__kmalloc_node_track_caller'

2010-04-09 06:29:37

by Xiaotian Feng

[permalink] [raw]
Subject: Re: [PATCH] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

On 04/09/2010 03:12 AM, David Rientjes wrote:
> On Thu, 8 Apr 2010, Xiaotian Feng wrote:
>
>> diff --git a/include/linux/slab.h b/include/linux/slab.h
>> index 4884462..1a0625c 100644
>> --- a/include/linux/slab.h
>> +++ b/include/linux/slab.h
>> @@ -267,7 +267,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
>> * allocator where we care about the real place the memory allocation
>> * request comes from.
>> */
>> -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
>> +#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || defined(CONFIG_TRACING)
>> extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
>> #define kmalloc_track_caller(size, flags) \
>> __kmalloc_track_caller(size, flags, _RET_IP_)
>> @@ -285,7 +285,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
>> * standard allocator where we care about the real place the memory
>> * allocation request comes from.
>> */
>> -#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
>> +#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || defined(CONFIG_TRACING)
>> extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
>> #define kmalloc_node_track_caller(size, flags, node) \
>> __kmalloc_node_track_caller(size, flags, node, \
>
> This doesn't work if the underlying slab allocator doesn't define
> __kmalloc_node_track_caller() regardless of whether CONFIG_TRACING is
> enabled or not. SLOB, for example, never defines it, and that's why the
> conditional exists in the way it currently does.
>

Sorry, I didn't realized this, can we use (defined(CONFIG_TRACING) &&
defined(CONFIG_SLAB)) ?

> This is your patch with CONFIG_EMBEDDED&& CONFIG_SLOB:
>
> mm/built-in.o: In function `__krealloc':
> (.text+0x1283c): undefined reference to `__kmalloc_track_caller'
> mm/built-in.o: In function `kmemdup':
> (.text+0x128b4): undefined reference to `__kmalloc_track_caller'
> mm/built-in.o: In function `kstrndup':
> (.text+0x128fc): undefined reference to `__kmalloc_track_caller'
> mm/built-in.o: In function `kstrdup':
> (.text+0x12943): undefined reference to `__kmalloc_track_caller'
> mm/built-in.o: In function `memdup_user':
> (.text+0x129f7): undefined reference to `__kmalloc_track_caller'
> drivers/built-in.o:(.text+0xc48a4): more undefined references to `__kmalloc_track_caller' follow
> net/built-in.o: In function `__alloc_skb':
> (.text+0x8dc6): undefined reference to `__kmalloc_node_track_caller'
>

2010-04-09 16:49:15

by David Rientjes

[permalink] [raw]
Subject: Re: [PATCH] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

On Fri, 9 Apr 2010, Xiaotian Feng wrote:

> > This doesn't work if the underlying slab allocator doesn't define
> > __kmalloc_node_track_caller() regardless of whether CONFIG_TRACING is
> > enabled or not. SLOB, for example, never defines it, and that's why the
> > conditional exists in the way it currently does.
> >
>
> Sorry, I didn't realized this, can we use (defined(CONFIG_TRACING) &&
> defined(CONFIG_SLAB)) ?
>

The valid configurations are

(CONFIG_SLAB && (CONFIG_DEBUG_SLAB || CONFIG_TRACING)) || CONFIG_SLUB

2010-06-30 09:58:18

by Xiaotian Feng

[permalink] [raw]
Subject: [PATCH V2] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

In slab, all __xxx_track_caller is defined on CONFIG_DEBUG_SLAB || CONFIG_TRACING,
thus caller tracking function should be worked for CONFIG_TRACING. But if
CONFIG_DEBUG_SLAB is not set, include/linux/slab.h will define xxx_track_caller to
__xxx() without consideration of CONFIG_TRACING. This will break the caller tracking
behaviour then.

Signed-off-by: Xiaotian Feng <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Matt Mackall <[email protected]>
Cc: Vegard Nossum <[email protected]>
Cc: Dmitry Monakhov <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: David Rientjes <[email protected]>
---
include/linux/slab.h | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 49d1247..59260e2 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -268,7 +268,8 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
* allocator where we care about the real place the memory allocation
* request comes from.
*/
-#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
+#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
+ (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
#define kmalloc_track_caller(size, flags) \
__kmalloc_track_caller(size, flags, _RET_IP_)
@@ -286,7 +287,8 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
* standard allocator where we care about the real place the memory
* allocation request comes from.
*/
-#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
+#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
+ (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
#define kmalloc_node_track_caller(size, flags, node) \
__kmalloc_node_track_caller(size, flags, node, \
--
1.7.0.1

2010-06-30 20:07:41

by David Rientjes

[permalink] [raw]
Subject: Re: [PATCH V2] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

On Wed, 30 Jun 2010, Xiaotian Feng wrote:

> In slab, all __xxx_track_caller is defined on CONFIG_DEBUG_SLAB || CONFIG_TRACING,
> thus caller tracking function should be worked for CONFIG_TRACING. But if
> CONFIG_DEBUG_SLAB is not set, include/linux/slab.h will define xxx_track_caller to
> __xxx() without consideration of CONFIG_TRACING. This will break the caller tracking
> behaviour then.
>
> Signed-off-by: Xiaotian Feng <[email protected]>
> Cc: Christoph Lameter <[email protected]>
> Cc: Pekka Enberg <[email protected]>
> Cc: Matt Mackall <[email protected]>
> Cc: Vegard Nossum <[email protected]>
> Cc: Dmitry Monakhov <[email protected]>
> Cc: Catalin Marinas <[email protected]>
> Cc: David Rientjes <[email protected]>

Acked-by: David Rientjes <[email protected]>

2010-07-04 16:51:05

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH V2] slab: fix caller tracking on !CONFIG_DEBUG_SLAB && CONFIG_TRACING

David Rientjes wrote:
> On Wed, 30 Jun 2010, Xiaotian Feng wrote:
>
>> In slab, all __xxx_track_caller is defined on CONFIG_DEBUG_SLAB || CONFIG_TRACING,
>> thus caller tracking function should be worked for CONFIG_TRACING. But if
>> CONFIG_DEBUG_SLAB is not set, include/linux/slab.h will define xxx_track_caller to
>> __xxx() without consideration of CONFIG_TRACING. This will break the caller tracking
>> behaviour then.
>>
>> Signed-off-by: Xiaotian Feng <[email protected]>
>> Cc: Christoph Lameter <[email protected]>
>> Cc: Pekka Enberg <[email protected]>
>> Cc: Matt Mackall <[email protected]>
>> Cc: Vegard Nossum <[email protected]>
>> Cc: Dmitry Monakhov <[email protected]>
>> Cc: Catalin Marinas <[email protected]>
>> Cc: David Rientjes <[email protected]>
>
> Acked-by: David Rientjes <[email protected]>

Applied, thanks!