All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use it in BUG.
@ 2009-09-10 23:54 ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:54 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, ralf,
	linux-mips, Martin Schwidefsky, Heiko Carstens, linux390,
	linux-s390, David Howells, Koichi Yasutake, linux-am33-list,
	Kyle McMartin, Helge Deller, linux-parisc,
	Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev,
	Richard Henderson, Ivan Kokshaysky, linux-alpha,
	Haavard Skinnemoen, Mike Frysinger, uclinux-dist-devel

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 allyesconfig 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.

01/10 adds the compiler.h support, the rest of the patches retrofit
the various architecture BUG macros to use it instead of for(;;) or
while(1) loops.

I will reply with the 10 patches.

The architecture specific patches I will send to a smaller set of
people.

David Daney (10):
   Add support for GCC-4.5's __builtin_unreachable() to compiler.h
   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()

  arch/alpha/include/asm/bug.h    |    2 +-
  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/linux/compiler-gcc4.h   |   14 ++++++++++++++
  include/linux/compiler.h        |    5 +++++
  11 files changed, 31 insertions(+), 13 deletions(-)


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

* [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use it in BUG.
@ 2009-09-10 23:54 ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:54 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	Ingo Molnar, Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

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 allyesconfig 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.

01/10 adds the compiler.h support, the rest of the patches retrofit
the various architecture BUG macros to use it instead of for(;;) or
while(1) loops.

I will reply with the 10 patches.

The architecture specific patches I will send to a smaller set of
people.

David Daney (10):
   Add support for GCC-4.5's __builtin_unreachable() to compiler.h
   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()

  arch/alpha/include/asm/bug.h    |    2 +-
  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/linux/compiler-gcc4.h   |   14 ++++++++++++++
  include/linux/compiler.h        |    5 +++++
  11 files changed, 31 insertions(+), 13 deletions(-)

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

* [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
  2009-09-10 23:54 ` David Daney
  (?)
  (?)
@ 2009-09-10 23:56   ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, ralf, linux-mips, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, David Howells,
	Koichi Yasutake, linux-am33-list, Kyle McMartin, Helge Deller,
	linux-parisc, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, Richard Henderson, Ivan Kokshaysky, linux-alpha,
	Haavard Skinnemoen, Mike Frysinger

Starting with version 4.5, GCC has a new built-in function
__builtin_unreachable() that can be used in places like the kernel's
BUG() where inline assembly is used to transfer control flow.  This
eliminated the need for an endless loop in these places.

The patch adds a new macro 'unreachable()' that will expand to either
__builtin_unreachable() or an endless loop depending on the compiler
version.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
CC: linux390@de.ibm.com
CC: linux-s390@vger.kernel.org
CC: David Howells <dhowells@redhat.com>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: linux-am33-list@redhat.com
CC: Kyle McMartin <kyle@mcmartin.ca>
CC: Helge Deller <deller@gmx.de>
CC: linux-parisc@vger.kernel.org
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: linux-alpha@vger.kernel.org
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: uclinux-dist-devel@blackfin.uclinux.org
---
 include/linux/compiler-gcc4.h |   14 ++++++++++++++
 include/linux/compiler.h      |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 450fa59..ab3af40 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -36,4 +36,18 @@
    the kernel context */
 #define __cold			__attribute__((__cold__))
 
+
+#if __GNUC_MINOR__ >= 5
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+#endif
+
 #endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 04fb513..7efd73f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -144,6 +144,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define barrier() __memory_barrier()
 #endif
 
+/* Unreachable code */
+#ifndef unreachable
+# define unreachable() do { for (;;) ; } while (0)
+#endif
+
 #ifndef RELOC_HIDE
 # define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-- 
1.6.2.5

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

* [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-10 23:56   ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, ralf, linux-mips, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, David Howells,
	Koichi Yasutake, linux-am33-list, Kyle McMartin, Helge Deller,
	linux-parisc, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, Richard Henderson, Ivan Kokshaysky, linux-alpha,
	Haavard Skinnemoen, Mike Frysinger, uclinux-dist-devel

Starting with version 4.5, GCC has a new built-in function
__builtin_unreachable() that can be used in places like the kernel's
BUG() where inline assembly is used to transfer control flow.  This
eliminated the need for an endless loop in these places.

The patch adds a new macro 'unreachable()' that will expand to either
__builtin_unreachable() or an endless loop depending on the compiler
version.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
CC: linux390@de.ibm.com
CC: linux-s390@vger.kernel.org
CC: David Howells <dhowells@redhat.com>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: linux-am33-list@redhat.com
CC: Kyle McMartin <kyle@mcmartin.ca>
CC: Helge Deller <deller@gmx.de>
CC: linux-parisc@vger.kernel.org
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: linux-alpha@vger.kernel.org
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: uclinux-dist-devel@blackfin.uclinux.org
---
 include/linux/compiler-gcc4.h |   14 ++++++++++++++
 include/linux/compiler.h      |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 450fa59..ab3af40 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -36,4 +36,18 @@
    the kernel context */
 #define __cold			__attribute__((__cold__))
 
+
+#if __GNUC_MINOR__ >= 5
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+#endif
+
 #endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 04fb513..7efd73f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -144,6 +144,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define barrier() __memory_barrier()
 #endif
 
+/* Unreachable code */
+#ifndef unreachable
+# define unreachable() do { for (;;) ; } while (0)
+#endif
+
 #ifndef RELOC_HIDE
 # define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-- 
1.6.2.5


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

* [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-10 23:56   ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, ralf, linux-mips, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, David Howells,
	Koichi Yasutake, linux-am33-list, Kyle McMartin, Helge Deller,
	linux-parisc, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, Richard Henderson, Ivan Kokshaysky, linux-alpha,
	Haavard Skinnemoen, Mike Frysinger

Starting with version 4.5, GCC has a new built-in function
__builtin_unreachable() that can be used in places like the kernel's
BUG() where inline assembly is used to transfer control flow.  This
eliminated the need for an endless loop in these places.

The patch adds a new macro 'unreachable()' that will expand to either
__builtin_unreachable() or an endless loop depending on the compiler
version.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
CC: linux390@de.ibm.com
CC: linux-s390@vger.kernel.org
CC: David Howells <dhowells@redhat.com>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: linux-am33-list@redhat.com
CC: Kyle McMartin <kyle@mcmartin.ca>
CC: Helge Deller <deller@gmx.de>
CC: linux-parisc@vger.kernel.org
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: linux-alpha@vger.kernel.org
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: uclinux-dist-devel@blackfin.uclinux.org
---
 include/linux/compiler-gcc4.h |   14 ++++++++++++++
 include/linux/compiler.h      |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 450fa59..ab3af40 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -36,4 +36,18 @@
    the kernel context */
 #define __cold			__attribute__((__cold__))
 
+
+#if __GNUC_MINOR__ >= 5
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+#endif
+
 #endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 04fb513..7efd73f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -144,6 +144,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define barrier() __memory_barrier()
 #endif
 
+/* Unreachable code */
+#ifndef unreachable
+# define unreachable() do { for (;;) ; } while (0)
+#endif
+
 #ifndef RELOC_HIDE
 # define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-- 
1.6.2.5

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

* [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-10 23:56   ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	David Daney, Ingo Molnar, Mike Frysinger, Ivan Kokshaysky,
	uclinux-dist-devel, Thomas Gleixner, Richard Henderson,
	Haavard Skinnemoen, linux-parisc, linux-kernel, ralf,
	Kyle McMartin, linux-alpha, Martin Schwidefsky, linux390,
	Koichi Yasutake

Starting with version 4.5, GCC has a new built-in function
__builtin_unreachable() that can be used in places like the kernel's
BUG() where inline assembly is used to transfer control flow.  This
eliminated the need for an endless loop in these places.

The patch adds a new macro 'unreachable()' that will expand to either
__builtin_unreachable() or an endless loop depending on the compiler
version.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
CC: linux390@de.ibm.com
CC: linux-s390@vger.kernel.org
CC: David Howells <dhowells@redhat.com>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: linux-am33-list@redhat.com
CC: Kyle McMartin <kyle@mcmartin.ca>
CC: Helge Deller <deller@gmx.de>
CC: linux-parisc@vger.kernel.org
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: linux-alpha@vger.kernel.org
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: uclinux-dist-devel@blackfin.uclinux.org
---
 include/linux/compiler-gcc4.h |   14 ++++++++++++++
 include/linux/compiler.h      |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 450fa59..ab3af40 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -36,4 +36,18 @@
    the kernel context */
 #define __cold			__attribute__((__cold__))
 
+
+#if __GNUC_MINOR__ >= 5
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+#endif
+
 #endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 04fb513..7efd73f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -144,6 +144,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define barrier() __memory_barrier()
 #endif
 
+/* Unreachable code */
+#ifndef unreachable
+# define unreachable() do { for (;;) ; } while (0)
+#endif
+
 #ifndef RELOC_HIDE
 # define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-- 
1.6.2.5

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

* [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
  (?)
  (?)
@ 2009-09-10 23:56 ` David Daney
  2009-09-11  0:56   ` H. Peter Anvin
  -1 siblings, 1 reply; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86

Use the new unreachable() macro instead of for(;;);.  When
allyesconfig is built with a GCC-4.5 snapshot on i686 the size of the
text segment is reduced by 3987 bytes (from 6827019 to 6823032).

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
---
 arch/x86/include/asm/bug.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index d9cf1cd..f654d1b 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -22,14 +22,14 @@ do {								\
 		     ".popsection"				\
 		     : : "i" (__FILE__), "i" (__LINE__),	\
 		     "i" (sizeof(struct bug_entry)));		\
-	for (;;) ;						\
+	unreachable();						\
 } while (0)
 
 #else
 #define BUG()							\
 do {								\
 	asm volatile("ud2");					\
-	for (;;) ;						\
+	unreachable();						\
 } while (0)
 #endif
 
-- 
1.6.2.5


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

* [PATCH 03/10] MIPS: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (2 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, David Daney, ralf, linux-mips

Use the new unreachable() macro instead of while(1);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
---
 arch/mips/include/asm/bug.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
index 6cf29c2..540c98a 100644
--- a/arch/mips/include/asm/bug.h
+++ b/arch/mips/include/asm/bug.h
@@ -11,9 +11,7 @@
 static inline void __noreturn BUG(void)
 {
 	__asm__ __volatile__("break %0" : : "i" (BRK_BUG));
-	/* Fool GCC into thinking the function doesn't return. */
-	while (1)
-		;
+	unreachable();
 }
 
 #define HAVE_ARCH_BUG
-- 
1.6.2.5


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

* [PATCH 04/10] s390: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (3 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  2009-09-11 12:18     ` Martin Schwidefsky
  -1 siblings, 1 reply; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Martin Schwidefsky, Heiko Carstens,
	linux390, linux-s390

Use the new unreachable() macro instead of for(;;);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
CC: linux390@de.ibm.com
CC: linux-s390@vger.kernel.org
---
 arch/s390/include/asm/bug.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h
index 7efd0ab..efb74fd 100644
--- a/arch/s390/include/asm/bug.h
+++ b/arch/s390/include/asm/bug.h
@@ -49,7 +49,7 @@
 
 #define BUG() do {					\
 	__EMIT_BUG(0);					\
-	for (;;);					\
+	unreachable();					\
 } while (0)
 
 #define WARN_ON(x) ({					\
-- 
1.6.2.5


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

* [PATCH 05/10] mn10300: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (4 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, David Howells, Koichi Yasutake,
	linux-am33-list

Use the new unreachable() macro instead of while(1).

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: David Howells <dhowells@redhat.com>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: linux-am33-list@redhat.com
---
 arch/mn10300/include/asm/bug.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/mn10300/include/asm/bug.h b/arch/mn10300/include/asm/bug.h
index aa6a388..447a7e6 100644
--- a/arch/mn10300/include/asm/bug.h
+++ b/arch/mn10300/include/asm/bug.h
@@ -27,7 +27,8 @@ do {								\
 		:						\
 		: "i"(__FILE__), "i"(__LINE__)			\
 		);						\
-} while (1)
+	unreachable();						\
+} while (0)
 
 #define HAVE_ARCH_BUG
 #endif /* CONFIG_BUG */
-- 
1.6.2.5


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

* [PATCH 06/10] parisc: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (5 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  2009-09-28  3:20   ` Kyle McMartin
  -1 siblings, 1 reply; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Kyle McMartin, Helge Deller, linux-parisc

Use the new unreachable() macro instead of for(;;);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Kyle McMartin <kyle@mcmartin.ca>
CC: Helge Deller <deller@gmx.de>
CC: linux-parisc@vger.kernel.org
---
 arch/parisc/include/asm/bug.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h
index 8cfc553..75e46c5 100644
--- a/arch/parisc/include/asm/bug.h
+++ b/arch/parisc/include/asm/bug.h
@@ -32,14 +32,14 @@
 			     "\t.popsection"				\
 			     : : "i" (__FILE__), "i" (__LINE__),	\
 			     "i" (0), "i" (sizeof(struct bug_entry)) ); \
-		for(;;) ;						\
+		unreachable();						\
 	} while(0)
 
 #else
 #define BUG()								\
 	do {								\
 		asm volatile(PARISC_BUG_BREAK_ASM : : );		\
-		for(;;) ;						\
+		unreachable();						\
 	} while(0)
 #endif
 
-- 
1.6.2.5

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

* [PATCH 07/10] powerpc: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
@ 2009-09-10 23:56   ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Benjamin Herrenschmidt,
	Paul Mackerras, linuxppc-dev

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

* [PATCH 07/10] powerpc: Convert BUG() to use unreachable()
@ 2009-09-10 23:56   ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linuxppc-dev, Paul Mackerras, linux-kernel, David Daney

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

* [PATCH 08/10] alpha: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (7 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Richard Henderson, Ivan Kokshaysky,
	linux-alpha

Use the new unreachable() macro instead of for(;;);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: linux-alpha@vger.kernel.org
---
 arch/alpha/include/asm/bug.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/alpha/include/asm/bug.h b/arch/alpha/include/asm/bug.h
index 1720c8a..53281f4 100644
--- a/arch/alpha/include/asm/bug.h
+++ b/arch/alpha/include/asm/bug.h
@@ -13,7 +13,7 @@
 		"call_pal %0  # bugchk\n\t"				\
 		".long %1\n\t.8byte %2"					\
 		: : "i"(PAL_bugchk), "i"(__LINE__), "i"(__FILE__));	\
-	for ( ; ; ); } while (0)
+	unreachable(); } while (0)
 
 #define HAVE_ARCH_BUG
 #endif
-- 
1.6.2.5


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

* [PATCH 09/10] avr32: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (8 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  2009-09-11  7:31   ` Haavard Skinnemoen
  -1 siblings, 1 reply; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, David Daney, Haavard Skinnemoen

Use the new unreachable() macro instead of for(;;);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
---
 arch/avr32/include/asm/bug.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/avr32/include/asm/bug.h b/arch/avr32/include/asm/bug.h
index 331d45b..2aa373c 100644
--- a/arch/avr32/include/asm/bug.h
+++ b/arch/avr32/include/asm/bug.h
@@ -52,7 +52,7 @@
 #define BUG()								\
 	do {								\
 		_BUG_OR_WARN(0);					\
-		for (;;);						\
+		unreachable();						\
 	} while (0)
 
 #define WARN_ON(condition)							\
-- 
1.6.2.5


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

* [PATCH 10/10] blackfin: Convert BUG() to use unreachable()
  2009-09-10 23:54 ` David Daney
                   ` (9 preceding siblings ...)
  (?)
@ 2009-09-10 23:56 ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-10 23:56 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Daney, Mike Frysinger, uclinux-dist-devel

Use the new unreachable() macro instead of for(;;);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: uclinux-dist-devel@blackfin.uclinux.org
---
 arch/blackfin/include/asm/bug.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/blackfin/include/asm/bug.h b/arch/blackfin/include/asm/bug.h
index 655e495..0b213a9 100644
--- a/arch/blackfin/include/asm/bug.h
+++ b/arch/blackfin/include/asm/bug.h
@@ -41,7 +41,7 @@
 #define BUG()								\
 	do {								\
 		_BUG_OR_WARN(0);					\
-		for (;;);						\
+		unreachable();						\
 	} while (0)
 
 #define WARN_ON(condition)							\
-- 
1.6.2.5


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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
  2009-09-10 23:56   ` David Daney
  (?)
@ 2009-09-11  0:14     ` Richard Henderson
  -1 siblings, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2009-09-11  0:14 UTC (permalink / raw)
  To: David Daney
  Cc: torvalds, akpm, linux-kernel, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, ralf, linux-mips, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, David Howells,
	Koichi Yasutake, linux-am33-list, Kyle McMartin, Helge Deller,
	linux-parisc, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, Ivan Kokshaysky, linux-alpha, Haavard Skinnemoen,
	Mike Frysinger, uclinux-d

On 09/10/2009 04:56 PM, David Daney wrote:
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

#define unreachable() do { } while (1)


r~

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11  0:14     ` Richard Henderson
  0 siblings, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2009-09-11  0:14 UTC (permalink / raw)
  To: David Daney
  Cc: torvalds, akpm, linux-kernel, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, ralf, linux-mips, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, David Howells,
	Koichi Yasutake, linux-am33-list, Kyle McMartin, Helge Deller,
	linux-parisc, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, Ivan Kokshaysky, linux-alpha, Haavard Skinnemoen,
	Mike Frysinger, uclinux-dist-devel

On 09/10/2009 04:56 PM, David Daney wrote:
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

#define unreachable() do { } while (1)


r~

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11  0:14     ` Richard Henderson
  0 siblings, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2009-09-11  0:14 UTC (permalink / raw)
  To: David Daney
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	Ingo Molnar, Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Haavard Skinnemoen, linux-parisc, linux-kernel,
	ralf, Kyle McMartin, linux-alpha, Martin Schwidefsky, linux390,
	akpm, Koichi Yasutake, torvalds

On 09/10/2009 04:56 PM, David Daney wrote:
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

#define unreachable() do { } while (1)


r~

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-10 23:56 ` [PATCH 02/10] x86: Convert BUG() to use unreachable() David Daney
@ 2009-09-11  0:56   ` H. Peter Anvin
  2009-09-11  1:09     ` Roland McGrath
  2009-09-11  1:13     ` Linus Torvalds
  0 siblings, 2 replies; 50+ messages in thread
From: H. Peter Anvin @ 2009-09-11  0:56 UTC (permalink / raw)
  To: David Daney
  Cc: torvalds, akpm, linux-kernel, Thomas Gleixner, Ingo Molnar, x86,
	Roland McGrath

On 09/10/2009 04:56 PM, David Daney wrote:
> Use the new unreachable() macro instead of for(;;);.  When
> allyesconfig is built with a GCC-4.5 snapshot on i686 the size of the
> text segment is reduced by 3987 bytes (from 6827019 to 6823032).
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: "H. Peter Anvin" <hpa@zytor.com>
> CC: x86@kernel.org

Acked-by: H. Peter Anvin <hpa@zytor.com>

... although of course this clashes with Roland McGrath's patchset for
the same thing which I applied earlier.  I have to say I like
unreachable() in lower case better though...

	-hpa

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  0:56   ` H. Peter Anvin
@ 2009-09-11  1:09     ` Roland McGrath
  2009-09-11  1:13     ` Linus Torvalds
  1 sibling, 0 replies; 50+ messages in thread
From: Roland McGrath @ 2009-09-11  1:09 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: David Daney, torvalds, akpm, linux-kernel, Thomas Gleixner,
	Ingo Molnar, x86

> ... although of course this clashes with Roland McGrath's patchset for
> the same thing which I applied earlier.  I have to say I like
> unreachable() in lower case better though...

I followed the example of existing function-like macros such as ACCESS_ONCE.
I have no preference about the name.


Thanks,
Roland

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  0:56   ` H. Peter Anvin
  2009-09-11  1:09     ` Roland McGrath
@ 2009-09-11  1:13     ` Linus Torvalds
  2009-09-11  1:33       ` H. Peter Anvin
                         ` (2 more replies)
  1 sibling, 3 replies; 50+ messages in thread
From: Linus Torvalds @ 2009-09-11  1:13 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: David Daney, akpm, linux-kernel, Thomas Gleixner, Ingo Molnar,
	x86, Roland McGrath



On Thu, 10 Sep 2009, H. Peter Anvin wrote:

> On 09/10/2009 04:56 PM, David Daney wrote:
> > Use the new unreachable() macro instead of for(;;);.  When
> > allyesconfig is built with a GCC-4.5 snapshot on i686 the size of the
> > text segment is reduced by 3987 bytes (from 6827019 to 6823032).
> > 
> > Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> > CC: Thomas Gleixner <tglx@linutronix.de>
> > CC: Ingo Molnar <mingo@redhat.com>
> > CC: "H. Peter Anvin" <hpa@zytor.com>
> > CC: x86@kernel.org
> 
> Acked-by: H. Peter Anvin <hpa@zytor.com>
> 
> ... although of course this clashes with Roland McGrath's patchset for
> the same thing which I applied earlier.  I have to say I like
> unreachable() in lower case better though...

I like David's version a bit better, since it takes care of more 
architectures, and also because it avoids that butt-ugly special case for 
gcc-4.4.1-RH-relase-10 backporting this feature.

I realize that the RH backport thing is good for testing now, but at the 
same time, it really does look nasty. I wonder if we could add some 
config-time compiler feature testing - so that you'd not have a version 
test at all, but a CONFIG_BUILTIN_UNREACHABLE.

There are other cases where that kind of config-time testing could be 
useful, and we could avoid doing various gcc checks dynamically from 
within 'make' (along with checking for known-buggy versions etc).

And yeah, it looks better in lower case. That said, I don't care _that_ 
much, and people can fight it out. 

		Linus

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  1:13     ` Linus Torvalds
@ 2009-09-11  1:33       ` H. Peter Anvin
  2009-09-11  1:37       ` Roland McGrath
  2009-09-11  6:07       ` Ingo Molnar
  2 siblings, 0 replies; 50+ messages in thread
From: H. Peter Anvin @ 2009-09-11  1:33 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Daney, akpm, linux-kernel, Thomas Gleixner, Ingo Molnar,
	x86, Roland McGrath

On 09/10/2009 06:13 PM, Linus Torvalds wrote:
> 
> I realize that the RH backport thing is good for testing now, but at the 
> same time, it really does look nasty. I wonder if we could add some 
> config-time compiler feature testing - so that you'd not have a version 
> test at all, but a CONFIG_BUILTIN_UNREACHABLE.
> 

autoconf ;)

	-hpa

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  1:13     ` Linus Torvalds
  2009-09-11  1:33       ` H. Peter Anvin
@ 2009-09-11  1:37       ` Roland McGrath
  2009-09-11  1:42         ` H. Peter Anvin
  2009-09-11  6:07       ` Ingo Molnar
  2 siblings, 1 reply; 50+ messages in thread
From: Roland McGrath @ 2009-09-11  1:37 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: H. Peter Anvin, David Daney, akpm, linux-kernel, Thomas Gleixner,
	Ingo Molnar, x86

> There are other cases where that kind of config-time testing could be 
> useful, and we could avoid doing various gcc checks dynamically from 
> within 'make' (along with checking for known-buggy versions etc).

I quite agree that this would be an improvement for many sorts of compiler
feature (and other tool detail) conditionalization.


Thanks,
Roland

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  1:37       ` Roland McGrath
@ 2009-09-11  1:42         ` H. Peter Anvin
  0 siblings, 0 replies; 50+ messages in thread
From: H. Peter Anvin @ 2009-09-11  1:42 UTC (permalink / raw)
  To: Roland McGrath
  Cc: Linus Torvalds, David Daney, akpm, linux-kernel, Thomas Gleixner,
	Ingo Molnar, x86

On 09/10/2009 06:37 PM, Roland McGrath wrote:
>> There are other cases where that kind of config-time testing could be 
>> useful, and we could avoid doing various gcc checks dynamically from 
>> within 'make' (along with checking for known-buggy versions etc).
> 
> I quite agree that this would be an improvement for many sorts of compiler
> feature (and other tool detail) conditionalization.

The nicest, of course, would be if gcc exported its internal support,
similar to the way it nowadays export macros for the various internal
data types.

	-hpa

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  1:13     ` Linus Torvalds
  2009-09-11  1:33       ` H. Peter Anvin
  2009-09-11  1:37       ` Roland McGrath
@ 2009-09-11  6:07       ` Ingo Molnar
  2009-09-11 15:55         ` David Daney
  2 siblings, 1 reply; 50+ messages in thread
From: Ingo Molnar @ 2009-09-11  6:07 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: H. Peter Anvin, David Daney, akpm, linux-kernel, Thomas Gleixner,
	Ingo Molnar, x86, Roland McGrath


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Thu, 10 Sep 2009, H. Peter Anvin wrote:
> 
> > On 09/10/2009 04:56 PM, David Daney wrote:
> > > Use the new unreachable() macro instead of for(;;);.  When
> > > allyesconfig is built with a GCC-4.5 snapshot on i686 the size of the
> > > text segment is reduced by 3987 bytes (from 6827019 to 6823032).
> > > 
> > > Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> > > CC: Thomas Gleixner <tglx@linutronix.de>
> > > CC: Ingo Molnar <mingo@redhat.com>
> > > CC: "H. Peter Anvin" <hpa@zytor.com>
> > > CC: x86@kernel.org
> > 
> > Acked-by: H. Peter Anvin <hpa@zytor.com>
> > 
> > ... although of course this clashes with Roland McGrath's 
> > patchset for the same thing which I applied earlier.  I have to 
> > say I like unreachable() in lower case better though...
> 
> I like David's version a bit better, since it takes care of more 
> architectures, and also because it avoids that butt-ugly special 
> case for gcc-4.4.1-RH-relase-10 backporting this feature.
> 
> I realize that the RH backport thing is good for testing now, but 
> at the same time, it really does look nasty. I wonder if we could 
> add some config-time compiler feature testing - so that you'd not 
> have a version test at all, but a CONFIG_BUILTIN_UNREACHABLE.
> 
> There are other cases where that kind of config-time testing could 
> be useful, and we could avoid doing various gcc checks dynamically 
> from within 'make' (along with checking for known-buggy versions 
> etc).
> 
> And yeah, it looks better in lower case. That said, I don't care 
> _that_ much, and people can fight it out.

Another detail that would be nice to be fixed is to propagate the 
unreachable() call into the !CONFIG_BUG case as well in 
asm-generic/bug.h.

That would kill dozens of !CONFIG_BUG compiler warnings and would 
make a dont-allow-warnings policy a possibility for random builds.

	Ingo

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

* Re: [PATCH 09/10] avr32: Convert BUG() to use unreachable()
  2009-09-10 23:56 ` [PATCH 09/10] avr32: " David Daney
@ 2009-09-11  7:31   ` Haavard Skinnemoen
  0 siblings, 0 replies; 50+ messages in thread
From: Haavard Skinnemoen @ 2009-09-11  7:31 UTC (permalink / raw)
  To: David Daney; +Cc: torvalds, akpm, linux-kernel, David Daney, Haavard Skinnemoen

David Daney <ddaney@caviumnetworks.com> wrote:
> Use the new unreachable() macro instead of for(;;);
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> CC: Haavard Skinnemoen <hskinnemoen@atmel.com>

Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>

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

* Re: [PATCH 04/10] s390: Convert BUG() to use unreachable()
  2009-09-10 23:56 ` [PATCH 04/10] s390: " David Daney
@ 2009-09-11 12:18     ` Martin Schwidefsky
  0 siblings, 0 replies; 50+ messages in thread
From: Martin Schwidefsky @ 2009-09-11 12:18 UTC (permalink / raw)
  To: David Daney
  Cc: torvalds, akpm, linux-kernel, David Daney, Heiko Carstens,
	linux390, linux-s390

On Thu, 10 Sep 2009 16:56:45 -0700
David Daney <ddaney@caviumnetworks.com> wrote:

> Use the new unreachable() macro instead of for(;;);
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
> CC: Heiko Carstens <heiko.carstens@de.ibm.com>
> CC: linux390@de.ibm.com
> CC: linux-s390@vger.kernel.org
> ---
>  arch/s390/include/asm/bug.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h
> index 7efd0ab..efb74fd 100644
> --- a/arch/s390/include/asm/bug.h
> +++ b/arch/s390/include/asm/bug.h
> @@ -49,7 +49,7 @@
> 
>  #define BUG() do {					\
>  	__EMIT_BUG(0);					\
> -	for (;;);					\
> +	unreachable();					\
>  } while (0)
> 
>  #define WARN_ON(x) ({					\

That seems simple enough ;-)

Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


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

* Re: [PATCH 04/10] s390: Convert BUG() to use unreachable()
@ 2009-09-11 12:18     ` Martin Schwidefsky
  0 siblings, 0 replies; 50+ messages in thread
From: Martin Schwidefsky @ 2009-09-11 12:18 UTC (permalink / raw)
  To: David Daney
  Cc: torvalds, akpm, linux-kernel, Heiko Carstens, linux390, linux-s390

On Thu, 10 Sep 2009 16:56:45 -0700
David Daney <ddaney@caviumnetworks.com> wrote:

> Use the new unreachable() macro instead of for(;;);
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
> CC: Heiko Carstens <heiko.carstens@de.ibm.com>
> CC: linux390@de.ibm.com
> CC: linux-s390@vger.kernel.org
> ---
>  arch/s390/include/asm/bug.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h
> index 7efd0ab..efb74fd 100644
> --- a/arch/s390/include/asm/bug.h
> +++ b/arch/s390/include/asm/bug.h
> @@ -49,7 +49,7 @@
> 
>  #define BUG() do {					\
>  	__EMIT_BUG(0);					\
> -	for (;;);					\
> +	unreachable();					\
>  } while (0)
> 
>  #define WARN_ON(x) ({					\

That seems simple enough ;-)

Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
  2009-09-10 23:56   ` David Daney
  (?)
@ 2009-09-11 14:32     ` Michael Buesch
  -1 siblings, 0 replies; 50+ messages in thread
From: Michael Buesch @ 2009-09-11 14:32 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	David Daney, Ingo Molnar, Mike Frysinger, Ivan Kokshaysky,
	linux390, Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, uclinux-dist-devel, akpm, Koichi Yasutake,
	torvalds

On Friday 11 September 2009 01:56:42 David Daney wrote:
> +/* Unreachable code */
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

# define unreachable() do { } while (1)

? :)

-- 
Greetings, Michael.

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11 14:32     ` Michael Buesch
  0 siblings, 0 replies; 50+ messages in thread
From: Michael Buesch @ 2009-09-11 14:32 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: David Daney, torvalds, akpm, linux-mips, Heiko Carstens,
	linuxppc-dev, Paul Mackerras, H. Peter Anvin, linux-s390,
	linux-am33-list, Helge Deller, x86, Ingo Molnar, Mike Frysinger,
	Ivan Kokshaysky, uclinux-dist-devel, Thomas Gleixner,
	Richard Henderson, Haavard Skinnemoen, linux-parisc,
	linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

On Friday 11 September 2009 01:56:42 David Daney wrote:
> +/* Unreachable code */
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

# define unreachable() do { } while (1)

? :)

-- 
Greetings, Michael.

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11 14:32     ` Michael Buesch
  0 siblings, 0 replies; 50+ messages in thread
From: Michael Buesch @ 2009-09-11 14:32 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	David Daney, Ingo Molnar, Mike Frysinger, Ivan Kokshaysky,
	linux390, Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, uclinux-dist-devel, akpm, Koichi Yasutake,
	torvalds

On Friday 11 September 2009 01:56:42 David Daney wrote:
> +/* Unreachable code */
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

# define unreachable() do { } while (1)

? :)

-- 
Greetings, Michael.

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11  6:07       ` Ingo Molnar
@ 2009-09-11 15:55         ` David Daney
  2009-09-13 20:12           ` H. Peter Anvin
  0 siblings, 1 reply; 50+ messages in thread
From: David Daney @ 2009-09-11 15:55 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Linus Torvalds, H. Peter Anvin, akpm, linux-kernel,
	Thomas Gleixner, Ingo Molnar, x86, Roland McGrath

Ingo Molnar wrote:
> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
>> On Thu, 10 Sep 2009, H. Peter Anvin wrote:
>>
>>> On 09/10/2009 04:56 PM, David Daney wrote:
>>>> Use the new unreachable() macro instead of for(;;);.  When
>>>> allyesconfig is built with a GCC-4.5 snapshot on i686 the size of the
>>>> text segment is reduced by 3987 bytes (from 6827019 to 6823032).
>>>>
>>>> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
>>>> CC: Thomas Gleixner <tglx@linutronix.de>
>>>> CC: Ingo Molnar <mingo@redhat.com>
>>>> CC: "H. Peter Anvin" <hpa@zytor.com>
>>>> CC: x86@kernel.org
>>> Acked-by: H. Peter Anvin <hpa@zytor.com>
>>>
>>> ... although of course this clashes with Roland McGrath's 
>>> patchset for the same thing which I applied earlier.  I have to 
>>> say I like unreachable() in lower case better though...
>> I like David's version a bit better, since it takes care of more 
>> architectures, and also because it avoids that butt-ugly special 
>> case for gcc-4.4.1-RH-relase-10 backporting this feature.
>>
>> I realize that the RH backport thing is good for testing now, but 
>> at the same time, it really does look nasty. I wonder if we could 
>> add some config-time compiler feature testing - so that you'd not 
>> have a version test at all, but a CONFIG_BUILTIN_UNREACHABLE.
>>
>> There are other cases where that kind of config-time testing could 
>> be useful, and we could avoid doing various gcc checks dynamically 
>> from within 'make' (along with checking for known-buggy versions 
>> etc).
>>
>> And yeah, it looks better in lower case. That said, I don't care 
>> _that_ much, and people can fight it out.
> 
> Another detail that would be nice to be fixed is to propagate the 
> unreachable() call into the !CONFIG_BUG case as well in 
> asm-generic/bug.h.
> 

Perhaps, although with a pre-GCC-4.5 compiler, it would end up adding 
the endless loop code to BUG() sites for configurations where the user 
has explicitly stated their preference for the code to be as small as 
possible (by turning off CONFIG_BUG).

If that is acceptable, I will prepare another revision of the patch set.

Thanks,
David Daney


> That would kill dozens of !CONFIG_BUG compiler warnings and would 
> make a dont-allow-warnings policy a possibility for random builds.
> 
> 	Ingo


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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
  2009-09-11 14:32     ` Michael Buesch
  (?)
  (?)
@ 2009-09-11 15:58       ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-11 15:58 UTC (permalink / raw)
  To: Michael Buesch
  Cc: linuxppc-dev, torvalds, akpm, linux-mips, Heiko Carstens,
	linuxppc-dev, Paul Mackerras, H. Peter Anvin, linux-s390,
	linux-am33-list, Helge Deller, x86, Ingo Molnar, Mike Frysinger,
	Ivan Kokshaysky, uclinux-dist-devel, Thomas Gleixner,
	Richard Henderson, Haavard Skinnemoen, linux-parisc,
	linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

Michael Buesch wrote:
> On Friday 11 September 2009 01:56:42 David Daney wrote:
>> +/* Unreachable code */
>> +#ifndef unreachable
>> +# define unreachable() do { for (;;) ; } while (0)
>> +#endif
> 
> # define unreachable() do { } while (1)
> 
> ? :)

Clearly I was not thinking clearly when I wrote that part.  RTH noted 
the same thing.  I will fix it.

Thanks,
David Daney

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11 15:58       ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-11 15:58 UTC (permalink / raw)
  To: Michael Buesch
  Cc: linuxppc-dev, torvalds, akpm, linux-mips, Heiko Carstens,
	linuxppc-dev, Paul Mackerras, H. Peter Anvin, linux-s390,
	linux-am33-list, Helge Deller, x86, Ingo Molnar, Mike Frysinger,
	Ivan Kokshaysky, uclinux-dist-devel, Thomas Gleixner,
	Richard Henderson, Haavard Skinnemoen, linux-parisc,
	linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

Michael Buesch wrote:
> On Friday 11 September 2009 01:56:42 David Daney wrote:
>> +/* Unreachable code */
>> +#ifndef unreachable
>> +# define unreachable() do { for (;;) ; } while (0)
>> +#endif
> 
> # define unreachable() do { } while (1)
> 
> ? :)

Clearly I was not thinking clearly when I wrote that part.  RTH noted 
the same thing.  I will fix it.

Thanks,
David Daney

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11 15:58       ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-11 15:58 UTC (permalink / raw)
  To: Michael Buesch
  Cc: linuxppc-dev, torvalds, akpm, linux-mips, Heiko Carstens,
	linuxppc-dev, Paul Mackerras, H. Peter Anvin, linux-s390,
	linux-am33-list, Helge Deller, x86, Ingo Molnar, Mike Frysinger,
	Ivan Kokshaysky, uclinux-dist-devel, Thomas Gleixner,
	Richard Henderson, Haavard Skinnemoen, linux-parisc,
	linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

Michael Buesch wrote:
> On Friday 11 September 2009 01:56:42 David Daney wrote:
>> +/* Unreachable code */
>> +#ifndef unreachable
>> +# define unreachable() do { for (;;) ; } while (0)
>> +#endif
> 
> # define unreachable() do { } while (1)
> 
> ? :)

Clearly I was not thinking clearly when I wrote that part.  RTH noted 
the same thing.  I will fix it.

Thanks,
David Daney

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-11 15:58       ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-11 15:58 UTC (permalink / raw)
  To: Michael Buesch
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	Ingo Molnar, Mike Frysinger, Ivan Kokshaysky, linux390,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, torvalds, linux-kernel, ralf, Kyle McMartin,
	linux-alpha, Martin Schwidefsky, uclinux-dist-devel, akpm,
	Koichi Yasutake, linuxppc-dev

Michael Buesch wrote:
> On Friday 11 September 2009 01:56:42 David Daney wrote:
>> +/* Unreachable code */
>> +#ifndef unreachable
>> +# define unreachable() do { for (;;) ; } while (0)
>> +#endif
> 
> # define unreachable() do { } while (1)
> 
> ? :)

Clearly I was not thinking clearly when I wrote that part.  RTH noted 
the same thing.  I will fix it.

Thanks,
David Daney

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
  2009-09-11 15:58       ` David Daney
                           ` (3 preceding siblings ...)
  (?)
@ 2009-09-12  7:22         ` Geert Uytterhoeven
  -1 siblings, 0 replies; 50+ messages in thread
From: Geert Uytterhoeven @ 2009-09-12  7:22 UTC (permalink / raw)
  To: David Daney
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> w=
rote:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part. =C2=A0RTH =
noted the
> same thing. =C2=A0I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-=
m68k.org

In personal conversations with technical people, I call myself a hacker=
=2E But
when I'm talking to journalists I just say "programmer" or something li=
ke that.
							    -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable()  to compiler.h
@ 2009-09-12  7:22         ` Geert Uytterhoeven
  0 siblings, 0 replies; 50+ messages in thread
From: Geert Uytterhoeven @ 2009-09-12  7:22 UTC (permalink / raw)
  To: David Daney
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
> same thing.  I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-12  7:22         ` Geert Uytterhoeven
  0 siblings, 0 replies; 50+ messages in thread
From: Geert Uytterhoeven @ 2009-09-12  7:22 UTC (permalink / raw)
  To: David Daney
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> w=
rote:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part. =C2=A0RTH =
noted the
> same thing. =C2=A0I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-=
m68k.org

In personal conversations with technical people, I call myself a hacker=
=2E But
when I'm talking to journalists I just say "programmer" or something li=
ke that.
							    -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-12  7:22         ` Geert Uytterhoeven
  0 siblings, 0 replies; 50+ messages in thread
From: Geert Uytterhoeven @ 2009-09-12  7:22 UTC (permalink / raw)
  To: David Daney
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
> same thing.  I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-12  7:22         ` Geert Uytterhoeven
  0 siblings, 0 replies; 50+ messages in thread
From: Geert Uytterhoeven @ 2009-09-12  7:22 UTC (permalink / raw)
  To: David Daney
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	Ingo Molnar, Mike Frysinger, Ivan Kokshaysky, linux390,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, torvalds, linux-kernel, ralf, Kyle McMartin,
	linux-alpha, Martin Schwidefsky, uclinux-dist-devel, akpm,
	Koichi Yasutake, linuxppc-dev

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote=
:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part. =C2=A0RTH note=
d the
> same thing. =C2=A0I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k=
.org

In personal conversations with technical people, I call myself a hacker. Bu=
t
when I'm talking to journalists I just say "programmer" or something like t=
hat.
							    -- Linus Torvalds

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable()  to compiler.h
@ 2009-09-12  7:22         ` Geert Uytterhoeven
  0 siblings, 0 replies; 50+ messages in thread
From: Geert Uytterhoeven @ 2009-09-12  7:22 UTC (permalink / raw)
  To: David Daney
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
> same thing.  I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 02/10] x86: Convert BUG() to use unreachable()
  2009-09-11 15:55         ` David Daney
@ 2009-09-13 20:12           ` H. Peter Anvin
  0 siblings, 0 replies; 50+ messages in thread
From: H. Peter Anvin @ 2009-09-13 20:12 UTC (permalink / raw)
  To: David Daney
  Cc: Ingo Molnar, Linus Torvalds, akpm, linux-kernel, Thomas Gleixner,
	Ingo Molnar, x86, Roland McGrath

On 09/11/2009 08:55 AM, David Daney wrote:
> 
> Perhaps, although with a pre-GCC-4.5 compiler, it would end up adding
> the endless loop code to BUG() sites for configurations where the user
> has explicitly stated their preference for the code to be as small as
> possible (by turning off CONFIG_BUG).
> 
> If that is acceptable, I will prepare another revision of the patch set.
> 

The thing is that without the loop, the compiler will generate the
fall-through case code, which may add more code than the loop removes.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
  2009-09-12  7:22         ` Geert Uytterhoeven
  (?)
  (?)
@ 2009-09-14 15:40           ` David Daney
  -1 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-14 15:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi

Geert Uytterhoeven wrote:
> On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
>> Michael Buesch wrote:
>>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>> +/* Unreachable code */
>>>> +#ifndef unreachable
>>>> +# define unreachable() do { for (;;) ; } while (0)
>>>> +#endif
>>> # define unreachable() do { } while (1)
>>>
>>> ? :)
>> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
>> same thing.  I will fix it.
> 
> However, people are so used to seeing the `do { } while (0)' idiom,
> that they might miss
> there's a `1' here, not a `0'.
> 
> So perhaps it's better to use plain `for (;;)' for infinite loops?
> 

I don't think so.  The only valid token that can follow 'do { } while 
(1)' is ';', any statement may follow 'for (;;)', so there is a greater 
possibility to silently screw things up with the for(;;) form.

David Daney


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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-14 15:40           ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-14 15:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi Yasutake

Geert Uytterhoeven wrote:
> On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
>> Michael Buesch wrote:
>>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>> +/* Unreachable code */
>>>> +#ifndef unreachable
>>>> +# define unreachable() do { for (;;) ; } while (0)
>>>> +#endif
>>> # define unreachable() do { } while (1)
>>>
>>> ? :)
>> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
>> same thing.  I will fix it.
> 
> However, people are so used to seeing the `do { } while (0)' idiom,
> that they might miss
> there's a `1' here, not a `0'.
> 
> So perhaps it's better to use plain `for (;;)' for infinite loops?
> 

I don't think so.  The only valid token that can follow 'do { } while 
(1)' is ';', any statement may follow 'for (;;)', so there is a greater 
possibility to silently screw things up with the for(;;) form.

David Daney


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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-14 15:40           ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-14 15:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Buesch, linuxppc-dev, torvalds, akpm, linux-mips,
	Heiko Carstens, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
	linux-s390, linux-am33-list, Helge Deller, x86, Ingo Molnar,
	Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, linux-kernel, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Koichi

Geert Uytterhoeven wrote:
> On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
>> Michael Buesch wrote:
>>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>> +/* Unreachable code */
>>>> +#ifndef unreachable
>>>> +# define unreachable() do { for (;;) ; } while (0)
>>>> +#endif
>>> # define unreachable() do { } while (1)
>>>
>>> ? :)
>> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
>> same thing.  I will fix it.
> 
> However, people are so used to seeing the `do { } while (0)' idiom,
> that they might miss
> there's a `1' here, not a `0'.
> 
> So perhaps it's better to use plain `for (;;)' for infinite loops?
> 

I don't think so.  The only valid token that can follow 'do { } while 
(1)' is ';', any statement may follow 'for (;;)', so there is a greater 
possibility to silently screw things up with the for(;;) form.

David Daney

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

* Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
@ 2009-09-14 15:40           ` David Daney
  0 siblings, 0 replies; 50+ messages in thread
From: David Daney @ 2009-09-14 15:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	Ingo Molnar, Mike Frysinger, Ivan Kokshaysky, linux390,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, torvalds, linux-kernel, ralf, Kyle McMartin,
	linux-alpha, Martin Schwidefsky, uclinux-dist-devel, akpm,
	Koichi Yasutake, linuxppc-dev

Geert Uytterhoeven wrote:
> On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
>> Michael Buesch wrote:
>>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>> +/* Unreachable code */
>>>> +#ifndef unreachable
>>>> +# define unreachable() do { for (;;) ; } while (0)
>>>> +#endif
>>> # define unreachable() do { } while (1)
>>>
>>> ? :)
>> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
>> same thing.  I will fix it.
> 
> However, people are so used to seeing the `do { } while (0)' idiom,
> that they might miss
> there's a `1' here, not a `0'.
> 
> So perhaps it's better to use plain `for (;;)' for infinite loops?
> 

I don't think so.  The only valid token that can follow 'do { } while 
(1)' is ';', any statement may follow 'for (;;)', so there is a greater 
possibility to silently screw things up with the for(;;) form.

David Daney

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

* Re: [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use it in BUG.
  2009-09-10 23:54 ` David Daney
                   ` (10 preceding siblings ...)
  (?)
@ 2009-09-24  3:37 ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 50+ messages in thread
From: Benjamin Herrenschmidt @ 2009-09-24  3:37 UTC (permalink / raw)
  To: David Daney
  Cc: linux-mips, Heiko Carstens, linuxppc-dev, Paul Mackerras,
	H. Peter Anvin, linux-s390, linux-am33-list, Helge Deller, x86,
	Ingo Molnar, Mike Frysinger, Ivan Kokshaysky, uclinux-dist-devel,
	Thomas Gleixner, Richard Henderson, Haavard Skinnemoen,
	linux-parisc, ralf, Kyle McMartin, linux-alpha,
	Martin Schwidefsky, linux390, Andrew Morton, Koichi Yasutake,
	Linus Torvalds

On Thu, 2009-09-10 at 16:54 -0700, David Daney wrote:
> 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 allyesconfig that is nearly 4000
> bytes smaller.

For the powerpc part:

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

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

* Re: [PATCH 06/10] parisc: Convert BUG() to use unreachable()
  2009-09-10 23:56 ` [PATCH 06/10] parisc: " David Daney
@ 2009-09-28  3:20   ` Kyle McMartin
  0 siblings, 0 replies; 50+ messages in thread
From: Kyle McMartin @ 2009-09-28  3:20 UTC (permalink / raw)
  To: David Daney
  Cc: torvalds, akpm, linux-kernel, Kyle McMartin, Helge Deller, linux-parisc

On Thu, Sep 10, 2009 at 04:56:47PM -0700, David Daney wrote:
> Use the new unreachable() macro instead of for(;;);
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> CC: Kyle McMartin <kyle@mcmartin.ca>
> CC: Helge Deller <deller@gmx.de>
> CC: linux-parisc@vger.kernel.org

Since the dependent part of this patch seems to have missed the merge
window, I guess we'll sit on this until next round?

--Kyle

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

end of thread, other threads:[~2009-09-28  3:20 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-10 23:54 [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use it in BUG David Daney
2009-09-10 23:54 ` David Daney
2009-09-10 23:56 ` [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h David Daney
2009-09-10 23:56   ` David Daney
2009-09-10 23:56   ` David Daney
2009-09-10 23:56   ` David Daney
2009-09-11  0:14   ` Richard Henderson
2009-09-11  0:14     ` Richard Henderson
2009-09-11  0:14     ` Richard Henderson
2009-09-11 14:32   ` Michael Buesch
2009-09-11 14:32     ` Michael Buesch
2009-09-11 14:32     ` Michael Buesch
2009-09-11 15:58     ` David Daney
2009-09-11 15:58       ` David Daney
2009-09-11 15:58       ` David Daney
2009-09-11 15:58       ` David Daney
2009-09-12  7:22       ` Geert Uytterhoeven
2009-09-12  7:22         ` Geert Uytterhoeven
2009-09-12  7:22         ` Geert Uytterhoeven
2009-09-12  7:22         ` Geert Uytterhoeven
2009-09-12  7:22         ` Geert Uytterhoeven
2009-09-12  7:22         ` Geert Uytterhoeven
2009-09-14 15:40         ` David Daney
2009-09-14 15:40           ` David Daney
2009-09-14 15:40           ` David Daney
2009-09-14 15:40           ` David Daney
2009-09-10 23:56 ` [PATCH 02/10] x86: Convert BUG() to use unreachable() David Daney
2009-09-11  0:56   ` H. Peter Anvin
2009-09-11  1:09     ` Roland McGrath
2009-09-11  1:13     ` Linus Torvalds
2009-09-11  1:33       ` H. Peter Anvin
2009-09-11  1:37       ` Roland McGrath
2009-09-11  1:42         ` H. Peter Anvin
2009-09-11  6:07       ` Ingo Molnar
2009-09-11 15:55         ` David Daney
2009-09-13 20:12           ` H. Peter Anvin
2009-09-10 23:56 ` [PATCH 03/10] MIPS: " David Daney
2009-09-10 23:56 ` [PATCH 04/10] s390: " David Daney
2009-09-11 12:18   ` Martin Schwidefsky
2009-09-11 12:18     ` Martin Schwidefsky
2009-09-10 23:56 ` [PATCH 05/10] mn10300: " David Daney
2009-09-10 23:56 ` [PATCH 06/10] parisc: " David Daney
2009-09-28  3:20   ` Kyle McMartin
2009-09-10 23:56 ` [PATCH 07/10] powerpc: " David Daney
2009-09-10 23:56   ` David Daney
2009-09-10 23:56 ` [PATCH 08/10] alpha: " David Daney
2009-09-10 23:56 ` [PATCH 09/10] avr32: " David Daney
2009-09-11  7:31   ` Haavard Skinnemoen
2009-09-10 23:56 ` [PATCH 10/10] blackfin: " David Daney
2009-09-24  3:37 ` [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use it in BUG Benjamin Herrenschmidt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.