linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slub: reduce total stack usage of slab_err & object_err
@ 2008-09-30 15:15 Richard Kennedy
  2008-09-30 15:32 ` Matt Mackall
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Richard Kennedy @ 2008-09-30 15:15 UTC (permalink / raw)
  To: Christoph Lameter, penberg, mpm; +Cc: linux-mm, lkml

reduce the total stack usage of slab_err & object_err.

Introduce a new function to display a simple slab bug message, and call
this when vprintk is not needed.

before: (stack size as reported by checkstack on x86_64)
	slab_err/object_err -> slab_bug(328)->printk
after:
	slab_err/object_err -> slab_bug_message(8) -> printk

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

----
I've been trying to build a tool to estimate the maximum stack usage in
the kernel, & noticed that most of the biggest stack users are the error
handling routines.
This simple change will reduced the stack used handling some slub errors
on both 64 & 32 bit platforms, although I haven't measured it on 32 bit
it will save at least 100 bytes. 
I haven't spotted anywhere that overflows the stack but this change
should reduce the chance of it happening.

It boots & run successfully on my AMD x86_64 desktop -- but I haven't
seen any slub errors so the new code hasn't been run.

regards
Richard


diff --git a/mm/slub.c b/mm/slub.c
index 0c83e6a..0646452 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -419,6 +419,15 @@ static void print_page_info(struct page *page)
 
 }
 
+static void slab_bug_message(struct kmem_cache *s, char *msg)
+{
+	printk(KERN_ERR "========================================"
+			"=====================================\n");
+	printk(KERN_ERR "BUG %s: %s\n", s->name, msg);
+	printk(KERN_ERR "----------------------------------------"
+			"-------------------------------------\n\n");
+}
+
 static void slab_bug(struct kmem_cache *s, char *fmt, ...)
 {
 	va_list args;
@@ -427,11 +436,7 @@ static void slab_bug(struct kmem_cache *s, char *fmt, ...)
 	va_start(args, fmt);
 	vsnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
-	printk(KERN_ERR "========================================"
-			"=====================================\n");
-	printk(KERN_ERR "BUG %s: %s\n", s->name, buf);
-	printk(KERN_ERR "----------------------------------------"
-			"-------------------------------------\n\n");
+	slab_bug_message(s, buf);
 }
 
 static void slab_fix(struct kmem_cache *s, char *fmt, ...)
@@ -484,7 +489,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
 static void object_err(struct kmem_cache *s, struct page *page,
 			u8 *object, char *reason)
 {
-	slab_bug(s, "%s", reason);
+	slab_bug_message(s, reason);
 	print_trailer(s, page, object);
 }
 
@@ -496,7 +501,7 @@ static void slab_err(struct kmem_cache *s, struct page *page, char *fmt, ...)
 	va_start(args, fmt);
 	vsnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
-	slab_bug(s, "%s", buf);
+	slab_bug_message(s, buf);
 	print_page_info(page);
 	dump_stack();
 }


--
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] 14+ messages in thread

end of thread, other threads:[~2008-10-01 10:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-30 15:15 [PATCH] slub: reduce total stack usage of slab_err & object_err Richard Kennedy
2008-09-30 15:32 ` Matt Mackall
2008-09-30 15:38 ` Christoph Lameter
2008-09-30 15:49   ` Matt Mackall
2008-09-30 16:20   ` Richard Kennedy
2008-09-30 16:43     ` Matt Mackall
2008-09-30 17:36     ` Christoph Lameter
2008-09-30 17:37     ` Matt Mackall
2008-09-30 18:33       ` Matt Mackall
2008-10-01  9:50         ` Richard Kennedy
2008-10-01  0:02     ` Matt Mackall
2008-09-30 19:33 ` Jörn Engel
2008-10-01 10:06   ` Richard Kennedy
2008-10-01 10:32     ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox