[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081124092048.GA21665@linux-mips.org>
Date: Mon, 24 Nov 2008 09:20:48 +0000
From: Ralf Baechle <ralf@...ux-mips.org>
To: Ingo Molnar <mingo@...e.hu>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
David Daney <ddaney@...iumnetworks.com>,
linux-mips@...ux-mips.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] MIPS: Make BUG() __noreturn.
On Sun, Nov 23, 2008 at 10:58:18AM +0100, Ingo Molnar wrote:
> yes - the total image effect is significantly - recently looked at how
> much larger !CONFIG_BUG builds would get if we inserted an infinite
> loop into them - it was in the 50K text range (!).
>
> but in the x86 ud2 case we could guarantee that we wont ever return
> from that exception. Mind sending a patch with a signoff, a
> description and an infinite loop in the u2d handler?
The infinite loop is necessary to keep gcc from creating pointless warnings.
But I did play a bit further with bug.h, this time on x86. Result below.
Ralf
[PATCH] x86: Optimize BUG() codesize.
Turning the i386 BUG() into an inline function shaves off 4064 bytes for
a defconfig kernel and 16 bytes for the same kernel with
CONFIG_DEBUG_BUGVERBOSE cleared. Tested with gcc 4.3.0.
Signed-off-by: Ralf Baechle <ralf@...ux-mips.org>
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 3def206..3b3bf2a 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -1,9 +1,10 @@
#ifndef _ASM_X86_BUG_H
#define _ASM_X86_BUG_H
-#ifdef CONFIG_BUG
#define HAVE_ARCH_BUG
+#include <asm-generic/bug.h>
+#ifdef CONFIG_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE
#ifdef CONFIG_X86_32
@@ -12,28 +13,27 @@
# define __BUG_C0 "2:\t.quad 1b, %c0\n"
#endif
-#define BUG() \
-do { \
- asm volatile("1:\tud2\n" \
- ".pushsection __bug_table,\"a\"\n" \
- __BUG_C0 \
- "\t.word %c1, 0\n" \
- "\t.org 2b+%c2\n" \
- ".popsection" \
- : : "i" (__FILE__), "i" (__LINE__), \
- "i" (sizeof(struct bug_entry))); \
- for (;;) ; \
-} while (0)
+static inline void BUG(void)
+{
+ asm volatile("1:\tud2\n"
+ ".pushsection __bug_table,\"a\"\n"
+ __BUG_C0
+ "\t.word %c1, 0\n"
+ "\t.org 2b+%c2\n"
+ ".popsection"
+ : : "i" (__FILE__), "i" (__LINE__),
+ "i" (sizeof(struct bug_entry)));
+ for (;;) ;
+}
#else
-#define BUG() \
-do { \
- asm volatile("ud2"); \
- for (;;) ; \
-} while (0)
+static inline void BUG(void)
+{
+ asm volatile("ud2");
+ for (;;) ;
+}
#endif
#endif /* !CONFIG_BUG */
-#include <asm-generic/bug.h>
#endif /* _ASM_X86_BUG_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists