* [PATCH 1/3] leak tracking for kmalloc_node
@ 2006-11-15 17:36 Christoph Hellwig
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2006-11-15 17:36 UTC (permalink / raw)
To: akpm, davem; +Cc: netdev, linux-mm
We have variants of kmalloc and kmem_cache_alloc that leave leak
tracking to the caller. This is used for subsystem-specific allocators
like skb_alloc.
To make skb_alloc node-aware we need similar routines for the node-aware
slab allocator, which this patch adds.
Note that the code is rather ugly, but it mirrors the non-node-aware
code 1:1:
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6/include/linux/slab.h
===================================================================
--- linux-2.6.orig/include/linux/slab.h 2006-10-23 17:20:14.000000000 +0200
+++ linux-2.6/include/linux/slab.h 2006-10-30 13:13:52.000000000 +0100
@@ -236,7 +236,25 @@
}
return __kmalloc_node(size, flags, node);
}
+
+/*
+ * kmalloc_node_track_caller is a special version of kmalloc_node that
+ * records the calling function of the routine calling it for slab leak
+ * tracking instead of just the calling function (confusing, eh?).
+ * It's useful when the call to kmalloc_node comes from a widely-used
+ * standard allocator where we care about the real place the memory
+ * allocation request comes from.
+ */
+#ifndef CONFIG_DEBUG_SLAB
+#define kmalloc_node_track_caller(size, flags, node) \
+ __kmalloc_node(size, flags, node)
#else
+extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
+#define kmalloc_node_track_caller(size, flags, node) \
+ __kmalloc_node_track_caller(size, flags, node, \
+ __builtin_return_address(0))
+#endif
+#else /* CONFIG_NUMA */
static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
{
return kmem_cache_alloc(cachep, flags);
@@ -245,6 +263,9 @@
{
return kmalloc(size, flags);
}
+
+#define kmalloc_node_track_caller(size, flags, node) \
+ kmalloc_track_caller(size, flags)
#endif
extern int FASTCALL(kmem_cache_reap(int));
@@ -283,6 +304,8 @@
#define kzalloc(s, f) __kzalloc(s, f)
#define kmalloc_track_caller kmalloc
+#define kmalloc_node_track_caller kmalloc_node
+
#endif /* CONFIG_SLOB */
/* System wide caches */
Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c 2006-10-23 17:21:47.000000000 +0200
+++ linux-2.6/mm/slab.c 2006-10-30 13:14:20.000000000 +0100
@@ -996,7 +996,7 @@
return NULL;
}
-static inline void *__cache_alloc_node(struct kmem_cache *cachep,
+static inline void *____cache_alloc_node(struct kmem_cache *cachep,
gfp_t flags, int nodeid)
{
return NULL;
@@ -1004,7 +1004,7 @@
#else /* CONFIG_NUMA */
-static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
+static void *____cache_alloc_node(struct kmem_cache *, gfp_t, int);
static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
static struct array_cache **alloc_alien_cache(int node, int limit)
@@ -3105,10 +3105,10 @@
objp = ____cache_alloc(cachep, flags);
/*
* We may just have run out of memory on the local node.
- * __cache_alloc_node() knows how to locate memory on other nodes
+ * ____cache_alloc_node() knows how to locate memory on other nodes
*/
if (NUMA_BUILD && !objp)
- objp = __cache_alloc_node(cachep, flags, numa_node_id());
+ objp = ____cache_alloc_node(cachep, flags, numa_node_id());
local_irq_restore(save_flags);
objp = cache_alloc_debugcheck_after(cachep, flags, objp,
caller);
@@ -3135,7 +3135,7 @@
else if (current->mempolicy)
nid_alloc = slab_node(current->mempolicy);
if (nid_alloc != nid_here)
- return __cache_alloc_node(cachep, flags, nid_alloc);
+ return ____cache_alloc_node(cachep, flags, nid_alloc);
return NULL;
}
@@ -3158,7 +3158,7 @@
if (zone_idx(*z) <= ZONE_NORMAL &&
cpuset_zone_allowed(*z, flags) &&
cache->nodelists[nid])
- obj = __cache_alloc_node(cache,
+ obj = ____cache_alloc_node(cache,
flags | __GFP_THISNODE, nid);
}
return obj;
@@ -3167,7 +3167,7 @@
/*
* A interface to enable slab creation on nodeid
*/
-static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
+static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
int nodeid)
{
struct list_head *entry;
@@ -3440,7 +3440,9 @@
* New and improved: it will now make sure that the object gets
* put on the correct node list so that there is no false sharing.
*/
-void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+static __always_inline void *
+__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
+ int nodeid, void *caller)
{
unsigned long save_flags;
void *ptr;
@@ -3452,17 +3454,22 @@
!cachep->nodelists[nodeid])
ptr = ____cache_alloc(cachep, flags);
else
- ptr = __cache_alloc_node(cachep, flags, nodeid);
+ ptr = ____cache_alloc_node(cachep, flags, nodeid);
local_irq_restore(save_flags);
- ptr = cache_alloc_debugcheck_after(cachep, flags, ptr,
- __builtin_return_address(0));
+ ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
return ptr;
}
-EXPORT_SYMBOL(kmem_cache_alloc_node);
-void *__kmalloc_node(size_t size, gfp_t flags, int node)
+void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+{
+ return __cache_alloc_node(cachep, flags, nodeid,
+ __builtin_return_address(0));
+}
+
+static __always_inline void *
+__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
{
struct kmem_cache *cachep;
@@ -3471,8 +3478,29 @@
return NULL;
return kmem_cache_alloc_node(cachep, flags, node);
}
+
+#ifdef CONFIG_DEBUG_SLAB
+void *__kmalloc_node(size_t size, gfp_t flags, int node)
+{
+ return __do_kmalloc_node(size, flags, node,
+ __builtin_return_address(0));
+}
EXPORT_SYMBOL(__kmalloc_node);
-#endif
+
+void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
+ int node, void *caller)
+{
+ return __do_kmalloc_node(size, flags, node, caller);
+}
+EXPORT_SYMBOL(__kmalloc_node_track_caller);
+#else
+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_NUMA */
/**
* __do_kmalloc - allocate memory
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3]: leak tracking for kmalloc node
2006-11-08 14:54 ` Pekka J Enberg
@ 2006-11-08 16:04 ` Andy Whitcroft
0 siblings, 0 replies; 8+ messages in thread
From: Andy Whitcroft @ 2006-11-08 16:04 UTC (permalink / raw)
To: Pekka J Enberg; +Cc: Christoph Hellwig, netdev, linux-mm
Pekka J Enberg wrote:
> Hi Andy,
>
> On Wed, 8 Nov 2006, Andy Whitcroft wrote:
>> I can give this a test, what is it based on...
>
> While you are at it, could you please give Christoph's NUMA leak tracking
> patch a spin too? I have included a rediffed version of it on top of
> my alloc path cleanup patch. Thanks!
Ok, submitted both of these for testing on a variety of architectures,
mostly NUMA's will let you know what happens. I'd expect the results on
TKO by tommorrow; someone has just dropped -rc5 and -rc5-mm1 on us :).
-apw
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3]: leak tracking for kmalloc node
2006-11-08 14:20 ` Andy Whitcroft
2006-11-08 14:29 ` Pekka Enberg
@ 2006-11-08 14:54 ` Pekka J Enberg
2006-11-08 16:04 ` Andy Whitcroft
1 sibling, 1 reply; 8+ messages in thread
From: Pekka J Enberg @ 2006-11-08 14:54 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: Christoph Hellwig, netdev, linux-mm
Hi Andy,
On Wed, 8 Nov 2006, Andy Whitcroft wrote:
> I can give this a test, what is it based on...
While you are at it, could you please give Christoph's NUMA leak tracking
patch a spin too? I have included a rediffed version of it on top of
my alloc path cleanup patch. Thanks!
Pekka
[PATCH] slab: leak tracking for kmalloc node
From: Christoph Hellwig <hch@lst.de>
If we want to use the node-aware kmalloc in __alloc_skb we need
the tracker is responsible for leak tracking magic for it. This
patch implements it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
include/linux/slab.h | 23 +++++++++++++++++++++++
mm/slab.c | 28 +++++++++++++++++++++++++---
2 files changed, 48 insertions(+), 3 deletions(-)
Index: 2.6/include/linux/slab.h
===================================================================
--- 2.6.orig/include/linux/slab.h
+++ 2.6/include/linux/slab.h
@@ -236,7 +236,25 @@ found:
}
return __kmalloc_node(size, flags, node);
}
+
+/*
+ * kmalloc_node_track_caller is a special version of kmalloc_node that
+ * records the calling function of the routine calling it for slab leak
+ * tracking instead of just the calling function (confusing, eh?).
+ * It's useful when the call to kmalloc_node comes from a widely-used
+ * standard allocator where we care about the real place the memory
+ * allocation request comes from.
+ */
+#ifndef CONFIG_DEBUG_SLAB
+#define kmalloc_node_track_caller(size, flags, node) \
+ __kmalloc_node(size, flags, node)
#else
+extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
+#define kmalloc_node_track_caller(size, flags, node) \
+ __kmalloc_node_track_caller(size, flags, node, \
+ __builtin_return_address(0))
+#endif
+#else /* CONFIG_NUMA */
static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
{
return kmem_cache_alloc(cachep, flags);
@@ -245,6 +263,9 @@ static inline void *kmalloc_node(size_t
{
return kmalloc(size, flags);
}
+
+#define kmalloc_node_track_caller(size, flags, node) \
+ kmalloc_track_caller(size, flags)
#endif
extern int FASTCALL(kmem_cache_reap(int));
@@ -283,6 +304,8 @@ static inline void *kcalloc(size_t n, si
#define kzalloc(s, f) __kzalloc(s, f)
#define kmalloc_track_caller kmalloc
+#define kmalloc_node_track_caller kmalloc_node
+
#endif /* CONFIG_SLOB */
/* System wide caches */
Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c
+++ 2.6/mm/slab.c
@@ -3478,17 +3478,39 @@ void *kmem_cache_alloc_node(struct kmem_
}
EXPORT_SYMBOL(kmem_cache_alloc_node);
-void *__kmalloc_node(size_t size, gfp_t flags, int node)
+static __always_inline void *__do_kmalloc_node(size_t size, gfp_t flags,
+ int node, void *caller)
{
struct kmem_cache *cachep;
cachep = kmem_find_general_cachep(size, flags);
if (unlikely(cachep == NULL))
return NULL;
- return kmem_cache_alloc_node(cachep, flags, node);
+ return cache_alloc(cachep, flags, node, caller);
+}
+
+#ifdef CONFIG_DEBUG_SLAB
+void *__kmalloc_node(size_t size, gfp_t flags, int node)
+{
+ return __do_kmalloc_node(size, flags, node,
+ __builtin_return_address(0));
}
EXPORT_SYMBOL(__kmalloc_node);
-#endif
+
+void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
+ int node, void *caller)
+{
+ return __do_kmalloc_node(size, flags, node, caller);
+}
+EXPORT_SYMBOL(__kmalloc_node_track_caller);
+#else
+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_NUMA */
/**
* __do_kmalloc - allocate memory
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3]: leak tracking for kmalloc node
2006-11-08 14:20 ` Andy Whitcroft
@ 2006-11-08 14:29 ` Pekka Enberg
2006-11-08 14:54 ` Pekka J Enberg
1 sibling, 0 replies; 8+ messages in thread
From: Pekka Enberg @ 2006-11-08 14:29 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: Christoph Hellwig, netdev, linux-mm
Hi Andy,
On 11/8/06, Andy Whitcroft <apw@shadowen.org> wrote:
> I can give this a test, what is it based on...
It should apply to current git head with some offsets. Thanks!
Pekka
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3]: leak tracking for kmalloc node
2006-10-30 14:32 ` Pekka Enberg
2006-10-30 14:52 ` Christoph Hellwig
@ 2006-11-08 14:20 ` Andy Whitcroft
2006-11-08 14:29 ` Pekka Enberg
2006-11-08 14:54 ` Pekka J Enberg
1 sibling, 2 replies; 8+ messages in thread
From: Andy Whitcroft @ 2006-11-08 14:20 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Christoph Hellwig, netdev, linux-mm
Pekka Enberg wrote:
> Hi,
>
> On 10/30/06, Christoph Hellwig <hch@lst.de> wrote:
>> If we want to use the node-aware kmalloc in __alloc_skb we need
>> the tracker is responsible for leak tracking magic for it. This
>> patch implements it. The code is far too ugly for my taste, but it's
>> doing exactly what the regular kmalloc is doing and thus follows it's
>> style.
>
> Yeah, the allocation paths are ugly. If only someone with NUMA machine
> could give this a shot so we can get it merged:
>
> http://marc.theaimsgroup.com/?l=linux-kernel&m=115952740803511&w=2
>
> Should clean up NUMA kmalloc tracking too.
I can give this a test, what is it based on...
-apw
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3]: leak tracking for kmalloc node
2006-10-30 14:32 ` Pekka Enberg
@ 2006-10-30 14:52 ` Christoph Hellwig
2006-11-08 14:20 ` Andy Whitcroft
1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2006-10-30 14:52 UTC (permalink / raw)
To: Pekka Enberg; +Cc: netdev, linux-mm
On Mon, Oct 30, 2006 at 04:32:57PM +0200, Pekka Enberg wrote:
> On 10/30/06, Christoph Hellwig <hch@lst.de> wrote:
> >If we want to use the node-aware kmalloc in __alloc_skb we need
> >the tracker is responsible for leak tracking magic for it. This
> >patch implements it. The code is far too ugly for my taste, but it's
> >doing exactly what the regular kmalloc is doing and thus follows it's
> >style.
>
> Yeah, the allocation paths are ugly. If only someone with NUMA machine
> could give this a shot so we can get it merged:
>
> http://marc.theaimsgroup.com/?l=linux-kernel&m=115952740803511&w=2
>
> Should clean up NUMA kmalloc tracking too.
I'll give this a try on a small numa machine (CELL with 2 nodes).
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3]: leak tracking for kmalloc node
2006-10-30 14:14 [PATCH 1/3]: leak tracking for kmalloc node Christoph Hellwig
@ 2006-10-30 14:32 ` Pekka Enberg
2006-10-30 14:52 ` Christoph Hellwig
2006-11-08 14:20 ` Andy Whitcroft
0 siblings, 2 replies; 8+ messages in thread
From: Pekka Enberg @ 2006-10-30 14:32 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: netdev, linux-mm
Hi,
On 10/30/06, Christoph Hellwig <hch@lst.de> wrote:
> If we want to use the node-aware kmalloc in __alloc_skb we need
> the tracker is responsible for leak tracking magic for it. This
> patch implements it. The code is far too ugly for my taste, but it's
> doing exactly what the regular kmalloc is doing and thus follows it's
> style.
Yeah, the allocation paths are ugly. If only someone with NUMA machine
could give this a shot so we can get it merged:
http://marc.theaimsgroup.com/?l=linux-kernel&m=115952740803511&w=2
Should clean up NUMA kmalloc tracking too.
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3]: leak tracking for kmalloc node
@ 2006-10-30 14:14 Christoph Hellwig
2006-10-30 14:32 ` Pekka Enberg
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2006-10-30 14:14 UTC (permalink / raw)
To: netdev, linux-mm
If we want to use the node-aware kmalloc in __alloc_skb we need
the tracker is responsible for leak tracking magic for it. This
patch implements it. The code is far too ugly for my taste, but it's
doing exactly what the regular kmalloc is doing and thus follows it's
style.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6/include/linux/slab.h
===================================================================
--- linux-2.6.orig/include/linux/slab.h 2006-10-23 17:20:14.000000000 +0200
+++ linux-2.6/include/linux/slab.h 2006-10-30 13:13:52.000000000 +0100
@@ -236,7 +236,25 @@
}
return __kmalloc_node(size, flags, node);
}
+
+/*
+ * kmalloc_node_track_caller is a special version of kmalloc_node that
+ * records the calling function of the routine calling it for slab leak
+ * tracking instead of just the calling function (confusing, eh?).
+ * It's useful when the call to kmalloc_node comes from a widely-used
+ * standard allocator where we care about the real place the memory
+ * allocation request comes from.
+ */
+#ifndef CONFIG_DEBUG_SLAB
+#define kmalloc_node_track_caller(size, flags, node) \
+ __kmalloc_node(size, flags, node)
#else
+extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
+#define kmalloc_node_track_caller(size, flags, node) \
+ __kmalloc_node_track_caller(size, flags, node, \
+ __builtin_return_address(0))
+#endif
+#else /* CONFIG_NUMA */
static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
{
return kmem_cache_alloc(cachep, flags);
@@ -245,6 +263,9 @@
{
return kmalloc(size, flags);
}
+
+#define kmalloc_node_track_caller(size, flags, node) \
+ kmalloc_track_caller(size, flags)
#endif
extern int FASTCALL(kmem_cache_reap(int));
@@ -283,6 +304,8 @@
#define kzalloc(s, f) __kzalloc(s, f)
#define kmalloc_track_caller kmalloc
+#define kmalloc_node_track_caller kmalloc_node
+
#endif /* CONFIG_SLOB */
/* System wide caches */
Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c 2006-10-23 17:21:47.000000000 +0200
+++ linux-2.6/mm/slab.c 2006-10-30 13:14:20.000000000 +0100
@@ -996,7 +996,7 @@
return NULL;
}
-static inline void *__cache_alloc_node(struct kmem_cache *cachep,
+static inline void *____cache_alloc_node(struct kmem_cache *cachep,
gfp_t flags, int nodeid)
{
return NULL;
@@ -1004,7 +1004,7 @@
#else /* CONFIG_NUMA */
-static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
+static void *____cache_alloc_node(struct kmem_cache *, gfp_t, int);
static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
static struct array_cache **alloc_alien_cache(int node, int limit)
@@ -3105,10 +3105,10 @@
objp = ____cache_alloc(cachep, flags);
/*
* We may just have run out of memory on the local node.
- * __cache_alloc_node() knows how to locate memory on other nodes
+ * ____cache_alloc_node() knows how to locate memory on other nodes
*/
if (NUMA_BUILD && !objp)
- objp = __cache_alloc_node(cachep, flags, numa_node_id());
+ objp = ____cache_alloc_node(cachep, flags, numa_node_id());
local_irq_restore(save_flags);
objp = cache_alloc_debugcheck_after(cachep, flags, objp,
caller);
@@ -3135,7 +3135,7 @@
else if (current->mempolicy)
nid_alloc = slab_node(current->mempolicy);
if (nid_alloc != nid_here)
- return __cache_alloc_node(cachep, flags, nid_alloc);
+ return ____cache_alloc_node(cachep, flags, nid_alloc);
return NULL;
}
@@ -3158,7 +3158,7 @@
if (zone_idx(*z) <= ZONE_NORMAL &&
cpuset_zone_allowed(*z, flags) &&
cache->nodelists[nid])
- obj = __cache_alloc_node(cache,
+ obj = ____cache_alloc_node(cache,
flags | __GFP_THISNODE, nid);
}
return obj;
@@ -3167,7 +3167,7 @@
/*
* A interface to enable slab creation on nodeid
*/
-static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
+static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
int nodeid)
{
struct list_head *entry;
@@ -3440,7 +3440,9 @@
* New and improved: it will now make sure that the object gets
* put on the correct node list so that there is no false sharing.
*/
-void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+static __always_inline void *
+__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
+ int nodeid, void *caller)
{
unsigned long save_flags;
void *ptr;
@@ -3452,17 +3454,22 @@
!cachep->nodelists[nodeid])
ptr = ____cache_alloc(cachep, flags);
else
- ptr = __cache_alloc_node(cachep, flags, nodeid);
+ ptr = ____cache_alloc_node(cachep, flags, nodeid);
local_irq_restore(save_flags);
- ptr = cache_alloc_debugcheck_after(cachep, flags, ptr,
- __builtin_return_address(0));
+ ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
return ptr;
}
-EXPORT_SYMBOL(kmem_cache_alloc_node);
-void *__kmalloc_node(size_t size, gfp_t flags, int node)
+void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
+{
+ return __cache_alloc_node(cachep, flags, nodeid,
+ __builtin_return_address(0));
+}
+
+static __always_inline void *
+__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
{
struct kmem_cache *cachep;
@@ -3471,8 +3478,29 @@
return NULL;
return kmem_cache_alloc_node(cachep, flags, node);
}
+
+#ifdef CONFIG_DEBUG_SLAB
+void *__kmalloc_node(size_t size, gfp_t flags, int node)
+{
+ return __do_kmalloc_node(size, flags, node,
+ __builtin_return_address(0));
+}
EXPORT_SYMBOL(__kmalloc_node);
-#endif
+
+void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
+ int node, void *caller)
+{
+ return __do_kmalloc_node(size, flags, node, caller);
+}
+EXPORT_SYMBOL(__kmalloc_node_track_caller);
+#else
+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_NUMA */
/**
* __do_kmalloc - allocate memory
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-11-15 17:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-15 17:36 [PATCH 1/3] leak tracking for kmalloc_node Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2006-10-30 14:14 [PATCH 1/3]: leak tracking for kmalloc node Christoph Hellwig
2006-10-30 14:32 ` Pekka Enberg
2006-10-30 14:52 ` Christoph Hellwig
2006-11-08 14:20 ` Andy Whitcroft
2006-11-08 14:29 ` Pekka Enberg
2006-11-08 14:54 ` Pekka J Enberg
2006-11-08 16:04 ` Andy Whitcroft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox