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 <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: "H. Peter Anvin" <[email protected]>
CC: [email protected]
---
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
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 <[email protected]>
> CC: Thomas Gleixner <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: "H. Peter Anvin" <[email protected]>
> CC: [email protected]
Acked-by: H. Peter Anvin <[email protected]>
... 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
> ... 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
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 <[email protected]>
> > CC: Thomas Gleixner <[email protected]>
> > CC: Ingo Molnar <[email protected]>
> > CC: "H. Peter Anvin" <[email protected]>
> > CC: [email protected]
>
> Acked-by: H. Peter Anvin <[email protected]>
>
> ... 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
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
> 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
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
* Linus Torvalds <[email protected]> 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 <[email protected]>
> > > CC: Thomas Gleixner <[email protected]>
> > > CC: Ingo Molnar <[email protected]>
> > > CC: "H. Peter Anvin" <[email protected]>
> > > CC: [email protected]
> >
> > Acked-by: H. Peter Anvin <[email protected]>
> >
> > ... 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
Ingo Molnar wrote:
> * Linus Torvalds <[email protected]> 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 <[email protected]>
>>>> CC: Thomas Gleixner <[email protected]>
>>>> CC: Ingo Molnar <[email protected]>
>>>> CC: "H. Peter Anvin" <[email protected]>
>>>> CC: [email protected]
>>> Acked-by: H. Peter Anvin <[email protected]>
>>>
>>> ... 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
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.