From: Ralf Baechle <ralf@linux-mips.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Daney <ddaney@caviumnetworks.com>,
linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Make BUG() __noreturn.
Date: Mon, 24 Nov 2008 09:20:48 +0000 [thread overview]
Message-ID: <20081124092048.GA21665@linux-mips.org> (raw)
In-Reply-To: <20081123095818.GU30453@elte.hu>
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@linux-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 */
next prev parent reply other threads:[~2008-11-24 9:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-21 1:26 [PATCH] MIPS: Make BUG() __noreturn David Daney
2008-11-21 10:00 ` Alan Cox
2008-11-21 10:27 ` Geert Uytterhoeven
2008-11-21 11:14 ` Maciej W. Rozycki
2008-11-21 12:58 ` Andreas Schwab
2008-11-21 16:40 ` David Daney
2008-11-21 18:46 ` Geert Uytterhoeven
2008-11-21 22:16 ` Ralf Baechle
2008-11-24 19:04 ` Maciej W. Rozycki
2008-11-21 23:00 ` Andrew Morton
2008-11-21 23:48 ` David Daney
2008-11-23 9:58 ` Ingo Molnar
2008-11-24 9:20 ` Ralf Baechle [this message]
2008-11-25 0:16 ` Jeremy Fitzhardinge
2008-11-22 9:39 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081124092048.GA21665@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=akpm@linux-foundation.org \
--cc=ddaney@caviumnetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox