linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RFC] slub tracing: move trace calls out of always inlined functions to reduce kernel code size
@ 2010-10-13 16:09 Richard Kennedy
  2010-10-14  7:09 ` Pekka Enberg
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kennedy @ 2010-10-13 16:09 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: lkml, linux-mm, Pekka Enberg, Steven Rostedt

Having the trace calls defined in the always inlined kmalloc functions
in include/linux/slub_def.h causes a lot of code duplication as the
trace functions get instantiated for each kamalloc call site. This can
simply be removed by pushing the trace calls down into the functions in
slub.c.

On my x86_64 built this patch shrinks the code size of the kernel by
approx 29K and also shrinks the code size of many modules -- too many to
list here ;)

size vmlinux.o reports
       text	   data	    bss	    dec	    hex	filename
    4777011	 602052	 763072	6142135	 5db8b7	vmlinux.o
    4747120	 602388	 763072	6112580	 5d4544	vmlinux.o.patch

The resulting kernel has had some testing & kmalloc trace still seems to
work.

This patch
- moves trace_kmalloc out of the inlined kmalloc() and pushes it down
into kmem_cache_alloc_trace() so this it only get instantiated once.

- rename kmem_cache_alloc_notrace()  to kmem_cache_alloc_trace() to
indicate that now is does have tracing. (maybe this would better being
called something like kmalloc_kmem_cache ?)

- adds a new function kmalloc_order() to handle allocation and tracing
of large allocations of page order.

- removes tracing from the inlined kmalloc_large() replacing them with a
call to kmalloc_order();

- move tracing out of inlined kmalloc_node() and pushing it down into
kmem_cache_alloc_node_trace

- rename kmem_cache_alloc_node_notrace() to
kmem_cache_alloc_node_trace()

- removes the include of trace/events/kmem.h from slub_def.h.

Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
-----
patch against v2.6.36-rc7
compiled & tested on x86_64.

Overall this lowers the overhead of having trace enabled & AFAICT seems
to still work ;)

Do you think this is the correct approach or can you suggest any better
way to do this?


regards
Richard

diffstat
 include/linux/slub_def.h |   40 ++++++++++------------------------------
 mm/slub.c                |   34 +++++++++++++++++++++++++++-------
 2 files changed, 37 insertions(+), 37 deletions(-)



diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 9f63538..314272a 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -10,9 +10,6 @@
 #include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/kobject.h>
-#include <linux/kmemleak.h>
-
-#include <trace/events/kmem.h>
 
 enum stat_item {
 	ALLOC_FASTPATH,		/* Allocation from cpu slab */
@@ -221,12 +218,13 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
 
 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 void *__kmalloc(size_t size, gfp_t flags);
+void *kmalloc_order(size_t size, gfp_t flags, unsigned int order);
 
 #ifdef CONFIG_TRACING
-extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags);
+extern void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size);
 #else
 static __always_inline void *
-kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
+kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
 {
 	return kmem_cache_alloc(s, gfpflags);
 }
@@ -235,18 +233,11 @@ kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
 static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
 {
 	unsigned int order = get_order(size);
-	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
-
-	kmemleak_alloc(ret, size, 1, flags);
-	trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);
-
-	return ret;
+	return kmalloc_order(size, flags, order);
 }
 
 static __always_inline void *kmalloc(size_t size, gfp_t flags)
 {
-	void *ret;
-
 	if (__builtin_constant_p(size)) {
 		if (size > SLUB_MAX_SIZE)
 			return kmalloc_large(size, flags);
@@ -257,11 +248,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
 			if (!s)
 				return ZERO_SIZE_PTR;
 
-			ret = kmem_cache_alloc_notrace(s, flags);
-
-			trace_kmalloc(_THIS_IP_, ret, size, s->size, flags);
-
-			return ret;
+			return kmem_cache_alloc_trace(s, flags, size);
 		}
 	}
 	return __kmalloc(size, flags);
@@ -272,14 +259,14 @@ 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_TRACING
-extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
 					   gfp_t gfpflags,
-					   int node);
+					   int node, size_t size);
 #else
 static __always_inline void *
-kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+kmem_cache_alloc_node_trace(struct kmem_cache *s,
 			      gfp_t gfpflags,
-			      int node)
+			      int node, size_t size)
 {
 	return kmem_cache_alloc_node(s, gfpflags, node);
 }
@@ -287,8 +274,6 @@ kmem_cache_alloc_node_notrace(struct kmem_cache *s,
 
 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 {
-	void *ret;
-
 	if (__builtin_constant_p(size) &&
 		size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) {
 			struct kmem_cache *s = kmalloc_slab(size);
@@ -296,12 +281,7 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 		if (!s)
 			return ZERO_SIZE_PTR;
 
-		ret = kmem_cache_alloc_node_notrace(s, flags, node);
-
-		trace_kmalloc_node(_THIS_IP_, ret,
-				   size, s->size, flags, node);
-
-		return ret;
+		return kmem_cache_alloc_node_trace(s, flags, node, size);
 	}
 	return __kmalloc_node(size, flags, node);
 }
diff --git a/mm/slub.c b/mm/slub.c
index 13fffe1..32b89ee 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -28,6 +28,9 @@
 #include <linux/math64.h>
 #include <linux/fault-inject.h>
 
+#include <linux/kmemleak.h>
+#include <trace/events/kmem.h>
+
 /*
  * Lock order:
  *   1. slab_lock(page)
@@ -1736,13 +1739,26 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
 EXPORT_SYMBOL(kmem_cache_alloc);
 
 #ifdef CONFIG_TRACING
-void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
+void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
 {
-	return slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_);
+	void *ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_);
+	trace_kmalloc(_RET_IP_, ret, size, s->size, gfpflags);
+	return ret;
 }
-EXPORT_SYMBOL(kmem_cache_alloc_notrace);
+EXPORT_SYMBOL(kmem_cache_alloc_trace);
 #endif
 
+void *kmalloc_order(size_t size, gfp_t flags, unsigned int order)
+{
+	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
+
+	kmemleak_alloc(ret, size, 1, flags);
+	trace_kmalloc(_RET_IP_, ret, size, PAGE_SIZE << order, flags);
+
+	return ret;
+}
+EXPORT_SYMBOL(kmalloc_order);
+
 #ifdef CONFIG_NUMA
 void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)
 {
@@ -1757,13 +1773,17 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
 #endif
 
 #ifdef CONFIG_TRACING
-void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
 				    gfp_t gfpflags,
-				    int node)
+				    int node, size_t size)
 {
-	return slab_alloc(s, gfpflags, node, _RET_IP_);
+	void *ret = slab_alloc(s, gfpflags, node, _RET_IP_);
+
+	trace_kmalloc_node(_RET_IP_, ret,
+			   size, s->size, gfpflags, node);
+	return ret;
 }
-EXPORT_SYMBOL(kmem_cache_alloc_node_notrace);
+EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
 #endif
 
 /*



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RFC] slub tracing: move trace calls out of always inlined functions to reduce kernel code size
  2010-10-13 16:09 [PATCH] [RFC] slub tracing: move trace calls out of always inlined functions to reduce kernel code size Richard Kennedy
@ 2010-10-14  7:09 ` Pekka Enberg
  2010-10-14  9:49   ` Richard Kennedy
  0 siblings, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2010-10-14  7:09 UTC (permalink / raw)
  To: Richard Kennedy; +Cc: Christoph Lameter, lkml, linux-mm, Steven Rostedt

  On 10/13/10 7:09 PM, Richard Kennedy wrote:
> Having the trace calls defined in the always inlined kmalloc functions
> in include/linux/slub_def.h causes a lot of code duplication as the
> trace functions get instantiated for each kamalloc call site. This can
> simply be removed by pushing the trace calls down into the functions in
> slub.c.
>
> On my x86_64 built this patch shrinks the code size of the kernel by
> approx 29K and also shrinks the code size of many modules -- too many to
> list here ;)
>
> size vmlinux.o reports
>         text	   data	    bss	    dec	    hex	filename
>      4777011	 602052	 763072	6142135	 5db8b7	vmlinux.o
>      4747120	 602388	 763072	6112580	 5d4544	vmlinux.o.patch

Impressive kernel text savings!

> index 13fffe1..32b89ee 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> +void *kmalloc_order(size_t size, gfp_t flags, unsigned int order)
> +{
> +	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
> +
> +	kmemleak_alloc(ret, size, 1, flags);
> +	trace_kmalloc(_RET_IP_, ret, size, PAGE_SIZE<<  order, flags);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(kmalloc_order);
> +
This doesn't make sense to be out-of-line for the !CONFIG_TRACE case. 
I'd just wrap that with "#ifdef CONFIG_TRACE" and put an inline version 
in the header for !TRACE.

             Pekka

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RFC] slub tracing: move trace calls out of always inlined functions to reduce kernel code size
  2010-10-14  7:09 ` Pekka Enberg
@ 2010-10-14  9:49   ` Richard Kennedy
  2010-10-21  9:29     ` [PATCH] [v2] " Richard Kennedy
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kennedy @ 2010-10-14  9:49 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Christoph Lameter, lkml, linux-mm, Steven Rostedt

On Thu, 2010-10-14 at 10:09 +0300, Pekka Enberg wrote:
> On 10/13/10 7:09 PM, Richard Kennedy wrote:
> > Having the trace calls defined in the always inlined kmalloc functions
> > in include/linux/slub_def.h causes a lot of code duplication as the
> > trace functions get instantiated for each kamalloc call site. This can
> > simply be removed by pushing the trace calls down into the functions in
> > slub.c.
> >
> > On my x86_64 built this patch shrinks the code size of the kernel by
> > approx 29K and also shrinks the code size of many modules -- too many to
> > list here ;)
> >
> > size vmlinux.o reports
> >         text	   data	    bss	    dec	    hex	filename
> >      4777011	 602052	 763072	6142135	 5db8b7	vmlinux.o
> >      4747120	 602388	 763072	6112580	 5d4544	vmlinux.o.patch
> 
> Impressive kernel text savings!
> 
> > index 13fffe1..32b89ee 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > +void *kmalloc_order(size_t size, gfp_t flags, unsigned int order)
> > +{
> > +	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
> > +
> > +	kmemleak_alloc(ret, size, 1, flags);
> > +	trace_kmalloc(_RET_IP_, ret, size, PAGE_SIZE<<  order, flags);
> > +
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL(kmalloc_order);
> > +
> This doesn't make sense to be out-of-line for the !CONFIG_TRACE case. 
> I'd just wrap that with "#ifdef CONFIG_TRACE" and put an inline version 
> in the header for !TRACE.
> 
>              Pekka

Yes, OK I'll do that.
regards
Richard


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [v2] slub tracing: move trace calls out of always inlined functions to reduce kernel code size
  2010-10-14  9:49   ` Richard Kennedy
@ 2010-10-21  9:29     ` Richard Kennedy
  2010-10-26 17:43       ` Pekka Enberg
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kennedy @ 2010-10-21  9:29 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Christoph Lameter, lkml, linux-mm, Steven Rostedt

Having the trace calls defined in the always inlined kmalloc functions
in include/linux/slub_def.h causes a lot of code duplication as the
trace functions get instantiated for each kamalloc call site. This can
simply be removed by pushing the trace calls down into the functions in
slub.c.

On my x86_64 built this patch shrinks the code size of the kernel by
approx 36K and also shrinks the code size of many modules -- too many to
list here ;)

size vmlinux (2.6.36) reports
       text        data     bss     dec     hex filename
    5410611	 743172	 828928	6982711	 6a8c37	vmlinux
    5373738	 744244	 828928	6946910	 6a005e	vmlinux + patch

The resulting kernel has had some testing & kmalloc trace still seems to
work.

This patch
- moves trace_kmalloc out of the inlined kmalloc() and pushes it down
into kmem_cache_alloc_trace() so this it only get instantiated once.

- rename kmem_cache_alloc_notrace()  to kmem_cache_alloc_trace() to
indicate that now is does have tracing. (maybe this would better being
called something like kmalloc_kmem_cache ?)

- adds a new function kmalloc_order() to handle allocation and tracing
of large allocations of page order.

- removes tracing from the inlined kmalloc_large() replacing them with a
call to kmalloc_order();

- move tracing out of inlined kmalloc_node() and pushing it down into
kmem_cache_alloc_node_trace

- rename kmem_cache_alloc_node_notrace() to
kmem_cache_alloc_node_trace()

- removes the include of trace/events/kmem.h from slub_def.h.

v2
- keep kmalloc_order_trace inline when !CONFIG_TRACE

Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>

----
patch against v2.6.36
compiled & tested on x86_64

regards
Richard

 include/linux/slub_def.h |   55 ++++++++++++++++++++++-------------------------
 mm/slub.c                |   30 +++++++++++++++++++------
 2 files changed, 49 insertions(+), 36 deletions(-)



diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 9f63538..d5a4ced 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -10,9 +10,8 @@
 #include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/kobject.h>
-#include <linux/kmemleak.h>
 
-#include <trace/events/kmem.h>
+#include <linux/kmemleak.h>
 
 enum stat_item {
 	ALLOC_FASTPATH,		/* Allocation from cpu slab */
@@ -222,31 +221,40 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 void *__kmalloc(size_t size, gfp_t flags);
 
+static __always_inline void *
+kmalloc_order(size_t size, gfp_t flags, unsigned int order)
+{
+	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
+	kmemleak_alloc(ret, size, 1, flags);
+	return ret;
+}
+
 #ifdef CONFIG_TRACING
-extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags);
+extern void *
+kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size);
+extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order);
 #else
 static __always_inline void *
-kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
+kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
 {
 	return kmem_cache_alloc(s, gfpflags);
 }
+
+static __always_inline void *
+kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
+{
+	return kmalloc_order(size, flags, order);
+}
 #endif
 
 static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
 {
 	unsigned int order = get_order(size);
-	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
-
-	kmemleak_alloc(ret, size, 1, flags);
-	trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);
-
-	return ret;
+	return kmalloc_order_trace(size, flags, order);
 }
 
 static __always_inline void *kmalloc(size_t size, gfp_t flags)
 {
-	void *ret;
-
 	if (__builtin_constant_p(size)) {
 		if (size > SLUB_MAX_SIZE)
 			return kmalloc_large(size, flags);
@@ -257,11 +265,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
 			if (!s)
 				return ZERO_SIZE_PTR;
 
-			ret = kmem_cache_alloc_notrace(s, flags);
-
-			trace_kmalloc(_THIS_IP_, ret, size, s->size, flags);
-
-			return ret;
+			return kmem_cache_alloc_trace(s, flags, size);
 		}
 	}
 	return __kmalloc(size, flags);
@@ -272,14 +276,14 @@ 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_TRACING
-extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
 					   gfp_t gfpflags,
-					   int node);
+					   int node, size_t size);
 #else
 static __always_inline void *
-kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+kmem_cache_alloc_node_trace(struct kmem_cache *s,
 			      gfp_t gfpflags,
-			      int node)
+			      int node, size_t size)
 {
 	return kmem_cache_alloc_node(s, gfpflags, node);
 }
@@ -287,8 +291,6 @@ kmem_cache_alloc_node_notrace(struct kmem_cache *s,
 
 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 {
-	void *ret;
-
 	if (__builtin_constant_p(size) &&
 		size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) {
 			struct kmem_cache *s = kmalloc_slab(size);
@@ -296,12 +298,7 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 		if (!s)
 			return ZERO_SIZE_PTR;
 
-		ret = kmem_cache_alloc_node_notrace(s, flags, node);
-
-		trace_kmalloc_node(_THIS_IP_, ret,
-				   size, s->size, flags, node);
-
-		return ret;
+		return kmem_cache_alloc_node_trace(s, flags, node, size);
 	}
 	return __kmalloc_node(size, flags, node);
 }
diff --git a/mm/slub.c b/mm/slub.c
index 13fffe1..aab2165 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -28,6 +28,8 @@
 #include <linux/math64.h>
 #include <linux/fault-inject.h>
 
+#include <trace/events/kmem.h>
+
 /*
  * Lock order:
  *   1. slab_lock(page)
@@ -1736,11 +1738,21 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
 EXPORT_SYMBOL(kmem_cache_alloc);
 
 #ifdef CONFIG_TRACING
-void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
+void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
+{
+	void *ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_);
+	trace_kmalloc(_RET_IP_, ret, size, s->size, gfpflags);
+	return ret;
+}
+EXPORT_SYMBOL(kmem_cache_alloc_trace);
+
+void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
 {
-	return slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_);
+	void *ret = kmalloc_order(size, flags, order);
+	trace_kmalloc(_RET_IP_, ret, size, PAGE_SIZE << order, flags);
+	return ret;
 }
-EXPORT_SYMBOL(kmem_cache_alloc_notrace);
+EXPORT_SYMBOL(kmalloc_order_trace);
 #endif
 
 #ifdef CONFIG_NUMA
@@ -1757,13 +1769,17 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
 #endif
 
 #ifdef CONFIG_TRACING
-void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
 				    gfp_t gfpflags,
-				    int node)
+				    int node, size_t size)
 {
-	return slab_alloc(s, gfpflags, node, _RET_IP_);
+	void *ret = slab_alloc(s, gfpflags, node, _RET_IP_);
+
+	trace_kmalloc_node(_RET_IP_, ret,
+			   size, s->size, gfpflags, node);
+	return ret;
 }
-EXPORT_SYMBOL(kmem_cache_alloc_node_notrace);
+EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
 #endif
 
 /*



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] [v2] slub tracing: move trace calls out of always inlined functions to reduce kernel code size
  2010-10-21  9:29     ` [PATCH] [v2] " Richard Kennedy
@ 2010-10-26 17:43       ` Pekka Enberg
  0 siblings, 0 replies; 5+ messages in thread
From: Pekka Enberg @ 2010-10-26 17:43 UTC (permalink / raw)
  To: Richard Kennedy; +Cc: Christoph Lameter, lkml, linux-mm, Steven Rostedt

On 21.10.2010 12.29, Richard Kennedy wrote:
> Having the trace calls defined in the always inlined kmalloc functions
> in include/linux/slub_def.h causes a lot of code duplication as the
> trace functions get instantiated for each kamalloc call site. This can
> simply be removed by pushing the trace calls down into the functions in
> slub.c.
>
> On my x86_64 built this patch shrinks the code size of the kernel by
> approx 36K and also shrinks the code size of many modules -- too many to
> list here ;)
>
> size vmlinux (2.6.36) reports
>         text        data     bss     dec     hex filename
>      5410611	 743172	 828928	6982711	 6a8c37	vmlinux
>      5373738	 744244	 828928	6946910	 6a005e	vmlinux + patch
>
> The resulting kernel has had some testing&  kmalloc trace still seems to
> work.
>
> This patch
> - moves trace_kmalloc out of the inlined kmalloc() and pushes it down
> into kmem_cache_alloc_trace() so this it only get instantiated once.
>
> - rename kmem_cache_alloc_notrace()  to kmem_cache_alloc_trace() to
> indicate that now is does have tracing. (maybe this would better being
> called something like kmalloc_kmem_cache ?)
>
> - adds a new function kmalloc_order() to handle allocation and tracing
> of large allocations of page order.
>
> - removes tracing from the inlined kmalloc_large() replacing them with a
> call to kmalloc_order();
>
> - move tracing out of inlined kmalloc_node() and pushing it down into
> kmem_cache_alloc_node_trace
>
> - rename kmem_cache_alloc_node_notrace() to
> kmem_cache_alloc_node_trace()
>
> - removes the include of trace/events/kmem.h from slub_def.h.
>
> v2
> - keep kmalloc_order_trace inline when !CONFIG_TRACE
>
> Signed-off-by: Richard Kennedy<richard@rsk.demon.co.uk>

Applied, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-26 17:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13 16:09 [PATCH] [RFC] slub tracing: move trace calls out of always inlined functions to reduce kernel code size Richard Kennedy
2010-10-14  7:09 ` Pekka Enberg
2010-10-14  9:49   ` Richard Kennedy
2010-10-21  9:29     ` [PATCH] [v2] " Richard Kennedy
2010-10-26 17:43       ` Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).