Skip to contentSkip to conversation

: leak tracking for kmalloc node]

PATCH In review Christoph Hellwig 1 participant 1 message Oct 30, 2006

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 : leak tracking for kmalloc node]

I should have noticed by now that netdev isn't at oss.sgi.com anymore..

----- Forwarded message from Christoph Hellwig <hch> -----

Date: Mon, 30 Oct 2006 15:14:54 +0100
From: Christoph Hellwig <hch>
Subject: [PATCH 1/3]: leak tracking for kmalloc node
To: [email protected], [email protected]

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.

include/linux/slab.h +23 -0
Index: linux-2.6/include/linux/slab.h
===================================================================
@@ -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 */
mm/slab.c +42 -14

119 lines not on this page · raw message

----- End forwarded message -----