* [PATCH 00/11] Add support for GCC's __builtin_unreachable() and use it in BUG (v2).
@ 2009-09-14 21:50 David Daney
2009-09-14 21:55 ` [PATCH 07/11] powerpc: Convert BUG() to use unreachable() David Daney
0 siblings, 1 reply; 2+ messages in thread
From: David Daney @ 2009-09-14 21:50 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
H. Peter Anvin, linux-arch, linux-s390, linux-am33-list,
Helge Deller, x86, Ingo Molnar, Mike Frysinger, Ivan Kokshaysky,
uclinux-dist-devel, Thomas Gleixner, Roland McGrath,
Richard Henderson, Haavard Skinnemoen, linux-parisc,
Linux Kernel Mailing List, ralf, Kyle McMartin, linux-alpha,
Martin Schwidefsky, linux390, Koichi Yasutake
When I sent the first version, I had not realized that Roland McGrath
had only a day or two earlier submitted a very similar patch (although
one that only fixed up the x86 case).
I have been working on this quite a while now, starting with adding
the required support to GCC, so with an eye towards finishing it up I
have this new version.
From the announcement of the first version:
Starting with version 4.5, GCC has a new built-in function called
__builtin_unreachable(). The function tells the compiler that control
flow will never reach that point. Currently we trick the compiler by
putting in for(;;); but this has the disadvantage that extra code is
emitted for an endless loop. For an i386 kernel using
__builtin_unreachable() results in an defaultconfig that is nearly 4000
bytes smaller.
This patch set adds support to compiler.h creating a
new macro usable in the kernel called unreachable(). If the compiler
lacks __builtin_unreachable(), it just expands to for(;;).
The x86 and MIPS patches I actually tested with a GCC-4.5 snapshot.
Lacking the ability to test the rest of the architectures, I just did
what seemed right without even trying to compile the kernel.
For version 2:
I fixed a couple of checkpatch issues, and simplified the
unreachable() macro for the pre-GCC-4.5 case (as suggested by Richard
Henderson). Also several Acked-by: were added.
New in this version (as suggested by Ingo Molnar) I added 11/11 which
uses unreachable() in asm-generic/bug.h for !CONFIG_BUG case. This
one may be a little controversial as it will end up making code
slightly larger when !CONFIG_BUG and you are using a pre-GCC-4.5
compiler.
I will reply with the 11 patches.
David Daney (11):
Add support for GCC-4.5's __builtin_unreachable() to compiler.h (v2)
x86: Convert BUG() to use unreachable()
MIPS: Convert BUG() to use unreachable()
s390: Convert BUG() to use unreachable()
mn10300: Convert BUG() to use unreachable()
parisc: Convert BUG() to use unreachable()
powerpc: Convert BUG() to use unreachable()
alpha: Convert BUG() to use unreachable()
avr32: Convert BUG() to use unreachable()
blackfin: Convert BUG() to use unreachable()
Use unreachable() in asm-generic/bug.h for !CONFIG_BUG case.
arch/alpha/include/asm/bug.h | 3 ++-
arch/avr32/include/asm/bug.h | 2 +-
arch/blackfin/include/asm/bug.h | 2 +-
arch/mips/include/asm/bug.h | 4 +---
arch/mn10300/include/asm/bug.h | 3 ++-
arch/parisc/include/asm/bug.h | 4 ++--
arch/powerpc/include/asm/bug.h | 2 +-
arch/s390/include/asm/bug.h | 2 +-
arch/x86/include/asm/bug.h | 4 ++--
include/asm-generic/bug.h | 4 ++--
include/linux/compiler-gcc4.h | 14 ++++++++++++++
include/linux/compiler.h | 5 +++++
12 files changed, 34 insertions(+), 15 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 07/11] powerpc: Convert BUG() to use unreachable()
2009-09-14 21:50 [PATCH 00/11] Add support for GCC's __builtin_unreachable() and use it in BUG (v2) David Daney
@ 2009-09-14 21:55 ` David Daney
0 siblings, 0 replies; 2+ messages in thread
From: David Daney @ 2009-09-14 21:55 UTC (permalink / raw)
To: torvalds, akpm
Cc: linux-arch, linux-kernel, David Daney, linuxppc-dev, Paul Mackerras
Use the new unreachable() macro instead of for(;;);
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
---
arch/powerpc/include/asm/bug.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 64e1fdc..2c15212 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -68,7 +68,7 @@
_EMIT_BUG_ENTRY \
: : "i" (__FILE__), "i" (__LINE__), \
"i" (0), "i" (sizeof(struct bug_entry))); \
- for(;;) ; \
+ unreachable(); \
} while (0)
#define BUG_ON(x) do { \
--
1.6.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-14 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-14 21:50 [PATCH 00/11] Add support for GCC's __builtin_unreachable() and use it in BUG (v2) David Daney
2009-09-14 21:55 ` [PATCH 07/11] powerpc: Convert BUG() to use unreachable() David Daney
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).