Skip to content

Add support for GCC's __builtin_unreachable() and use it in BUG.

David Daney linux-alpha linux-mips linux-parisc linux-s390 linuxppc-dev lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10Add support for GCC-4.5's __builtin_unreachable() to compiler.hinclude/linux/compiler-gcc4.h include/linux/compiler.h+19 -05 replies
2/10x86: Convert BUG() to use unreachable()arch/x86/include/asm/bug.h+2 -29 replies
3/10MIPS: Convert BUG() to use unreachable()arch/mips/include/asm/bug.h+1 -30 replies
4/10s390: Convert BUG() to use unreachable()arch/s390/include/asm/bug.h+1 -11 reply
5/10mn10300: Convert BUG() to use unreachable()arch/mn10300/include/asm/bug.h+2 -10 replies
6/10parisc: Convert BUG() to use unreachable()arch/parisc/include/asm/bug.h+2 -21 reply
7/10powerpc: Convert BUG() to use unreachable()arch/powerpc/include/asm/bug.h+1 -10 replies
8/10alpha: Convert BUG() to use unreachable()arch/alpha/include/asm/bug.h+1 -10 replies
9/10avr32: Convert BUG() to use unreachable()arch/avr32/include/asm/bug.h+1 -11 reply
10/10blackfin: Convert BUG() to use unreachable()arch/blackfin/include/asm/bug.h+1 -10 replies

Reviews trailers per patch

3 of 10 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchH. Peter AnvinHaavard SkinnemoenMartin SchwidefskyBenjamin Herrenschmidt
SeriesA-b
1/10
2/10A-b
3/10
4/10A-b
5/10
6/10
7/10
8/10
9/10A-b
10/10

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use it in BUG.

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(-)