linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fyi: gcc33-hammer crashes when compiling kvm emulate.c
@ 2010-10-26 12:38 Andi Kleen
  2010-10-26 16:34 ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2010-10-26 12:38 UTC (permalink / raw)
  To: linux-kvm, avi, hpa; +Cc: linux-kernel

Hi,

While doing a test run with the minimum supported compiler
I found:

An old gcc 3.3-hammer segfaults when compiling the current KVM
emulate.c (or rather in x86_emulate_insns) on x86-64.

The compiler goes into an endless recursion in validate_rtx and then
eventually overflows the stack and dies.

I minimized a test case, but didn't find a workaround
(minimized test case http://halobates.de/emulate-min.i)

My guess it's related to some of the inline assembler uses.

This might be an excuse to bump the minimum compiler version again.

-andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 12:38 fyi: gcc33-hammer crashes when compiling kvm emulate.c Andi Kleen
@ 2010-10-26 16:34 ` H. Peter Anvin
  2010-10-26 16:37   ` Andi Kleen
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2010-10-26 16:34 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kvm, avi, linux-kernel

On 10/26/2010 05:38 AM, Andi Kleen wrote:
> Hi,
> 
> While doing a test run with the minimum supported compiler
> I found:
> 
> An old gcc 3.3-hammer segfaults when compiling the current KVM
> emulate.c (or rather in x86_emulate_insns) on x86-64.
> 
> The compiler goes into an endless recursion in validate_rtx and then
> eventually overflows the stack and dies.
> 
> I minimized a test case, but didn't find a workaround
> (minimized test case http://halobates.de/emulate-min.i)
> 
> My guess it's related to some of the inline assembler uses.
> 
> This might be an excuse to bump the minimum compiler version again.
> 

We have said 3.4 minimum for x86 for a long time now, and have an RFC
out to bump to 4.1.  Unfortunately there isn't a good repo of
arch-specific version requirements in the kernel source code; in fact, I
just talked to Tony Luck yesterday about the need for that.

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 16:34 ` H. Peter Anvin
@ 2010-10-26 16:37   ` Andi Kleen
  2010-10-26 16:46     ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2010-10-26 16:37 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Andi Kleen, kvm, avi, linux-kernel

> We have said 3.4 minimum for x86 for a long time now, and have an RFC

Ok makes sense. I thought it was still at 3.3. I should retire
this 3.3 fossil anyways, it's really only for old compat testing.

I don't remember seeing a warning -- aren't there supposed to be warnings
for unsupported compilers?

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 16:37   ` Andi Kleen
@ 2010-10-26 16:46     ` H. Peter Anvin
  2010-10-26 17:01       ` Andi Kleen
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2010-10-26 16:46 UTC (permalink / raw)
  To: Andi Kleen; +Cc: kvm, avi, linux-kernel

On 10/26/2010 09:37 AM, Andi Kleen wrote:
>> We have said 3.4 minimum for x86 for a long time now, and have an RFC
> 
> Ok makes sense. I thought it was still at 3.3. I should retire
> this 3.3 fossil anyways, it's really only for old compat testing.
> 
> I don't remember seeing a warning -- aren't there supposed to be warnings
> for unsupported compilers?
> 

Not unless they are actively known to break.  People get huffy about it
because even if it is known to have problems it doesn't break *their*
particular configuration.  I'm getting to be of the opinion that people
who compile modern kernels with ancient compilers and expect it to work
are suffering from some particular kind of insanity -- it's nothing the
distros do.  The only exception are embedded people who compile with the
latest 3.4 gcc; they have explained they do so because newer gccs have
too many dependencies (the actual compiler, not the generated code) and
for speed.

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 16:46     ` H. Peter Anvin
@ 2010-10-26 17:01       ` Andi Kleen
  2010-10-26 18:19         ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2010-10-26 17:01 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Andi Kleen, kvm, avi, linux-kernel

> Not unless they are actively known to break.  People get huffy about it

Well they do -- i just found out.

> because even if it is known to have problems it doesn't break *their*
> particular configuration.  I'm getting to be of the opinion that people
> who compile modern kernels with ancient compilers and expect it to work
> are suffering from some particular kind of insanity -- it's nothing the
> distros do.  The only exception are embedded people who compile with the
> latest 3.4 gcc; they have explained they do so because newer gccs have
> too many dependencies (the actual compiler, not the generated code) and
> for speed.

At least in the old days the main reason for gcc 3 was build speed.
AKPM and some others used to be fond of that.

3.x is apparently much faster than 4.x

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 17:01       ` Andi Kleen
@ 2010-10-26 18:19         ` H. Peter Anvin
  2010-10-26 20:27           ` Andi Kleen
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2010-10-26 18:19 UTC (permalink / raw)
  To: Andi Kleen; +Cc: kvm, avi, linux-kernel

On 10/26/2010 10:01 AM, Andi Kleen wrote:
>> Not unless they are actively known to break.  People get huffy about it
> 
> Well they do -- i just found out.

Sounds like a good reason to put in a warning or error.

>> because even if it is known to have problems it doesn't break *their*
>> particular configuration.  I'm getting to be of the opinion that people
>> who compile modern kernels with ancient compilers and expect it to work
>> are suffering from some particular kind of insanity -- it's nothing the
>> distros do.  The only exception are embedded people who compile with the
>> latest 3.4 gcc; they have explained they do so because newer gccs have
>> too many dependencies (the actual compiler, not the generated code) and
>> for speed.
> 
> At least in the old days the main reason for gcc 3 was build speed.
> AKPM and some others used to be fond of that.
> 
> 3.x is apparently much faster than 4.x

That is an issue too, as 3.x does a lot fewer optimizations than 4.x.

	-hpa

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 18:19         ` H. Peter Anvin
@ 2010-10-26 20:27           ` Andi Kleen
  2010-10-26 20:37             ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2010-10-26 20:27 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Andi Kleen, kvm, avi, linux-kernel

> That is an issue too, as 3.x does a lot fewer optimizations than 4.x.

Well to be fair the default -Os build disables most of the fancy stuff
(and the resulting code is often terrible) 

I guess it doesn't matter too much, at least not with the 
CONFIG_CC_OPTIMIZE_SIZE default.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 20:27           ` Andi Kleen
@ 2010-10-26 20:37             ` H. Peter Anvin
  2010-10-27 10:50               ` Avi Kivity
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2010-10-26 20:37 UTC (permalink / raw)
  To: Andi Kleen; +Cc: kvm, avi, linux-kernel

On 10/26/2010 01:27 PM, Andi Kleen wrote:
>> That is an issue too, as 3.x does a lot fewer optimizations than 4.x.
> 
> Well to be fair the default -Os build disables most of the fancy stuff
> (and the resulting code is often terrible) 
> 
> I guess it doesn't matter too much, at least not with the 
> CONFIG_CC_OPTIMIZE_SIZE default.
> 

Yes, it would be nice to have a setting which is "optimize but don't
bloat excessively."

	-hpa

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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-26 20:37             ` H. Peter Anvin
@ 2010-10-27 10:50               ` Avi Kivity
  2010-10-27 17:00                 ` Andi Kleen
  0 siblings, 1 reply; 10+ messages in thread
From: Avi Kivity @ 2010-10-27 10:50 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Andi Kleen, kvm, linux-kernel

  On 10/26/2010 10:37 PM, H. Peter Anvin wrote:
> On 10/26/2010 01:27 PM, Andi Kleen wrote:
> >>  That is an issue too, as 3.x does a lot fewer optimizations than 4.x.
> >
> >  Well to be fair the default -Os build disables most of the fancy stuff
> >  (and the resulting code is often terrible)
> >
> >  I guess it doesn't matter too much, at least not with the
> >  CONFIG_CC_OPTIMIZE_SIZE default.
> >
>
> Yes, it would be nice to have a setting which is "optimize but don't
> bloat excessively."
>

Would be good to have __fastpath and __slowpath function attributes.

__fastpath would always be optimized for speed, __slowpath always for 
size, and everything else would use the default (determined by 
CONFIG_CC_OPTIMIZE_FOR_SIZE).

Looks like gcc has support for this, with __attribute__((hot)), 
__attribute__((cold)), and __attribute__((optimize)).

-- 
error compiling committee.c: too many arguments to function


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

* Re: fyi: gcc33-hammer crashes when compiling kvm emulate.c
  2010-10-27 10:50               ` Avi Kivity
@ 2010-10-27 17:00                 ` Andi Kleen
  0 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2010-10-27 17:00 UTC (permalink / raw)
  To: Avi Kivity; +Cc: H. Peter Anvin, Andi Kleen, kvm, linux-kernel

> Would be good to have __fastpath and __slowpath function attributes.
> 
> __fastpath would always be optimized for speed, __slowpath always
> for size, and everything else would use the default (determined by
> CONFIG_CC_OPTIMIZE_FOR_SIZE).

> 
> Looks like gcc has support for this, with __attribute__((hot)),
> __attribute__((cold)), and __attribute__((optimize)).

I had patches for a long time, but last time I tried it didn't help too much.
(basically make __init hot/cold and mark a few functions) 
Similar things can be also done with unrolling. The Optimize attribute
is currently quite broken in gcc and shouldn't be used.

The main reason I didn't post them is that I didn't want another
likely/unlikely with people sprinkling them randomly and never
looking at profile logs. I am to blame for likely()/unlikely() originally
 and it got abused so much that I regretted it alot. So I don't
think just exposing that is a good idea right now.

I think there are some other ways to do that better, but they
will need more work.

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only.

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

end of thread, other threads:[~2010-10-27 17:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 12:38 fyi: gcc33-hammer crashes when compiling kvm emulate.c Andi Kleen
2010-10-26 16:34 ` H. Peter Anvin
2010-10-26 16:37   ` Andi Kleen
2010-10-26 16:46     ` H. Peter Anvin
2010-10-26 17:01       ` Andi Kleen
2010-10-26 18:19         ` H. Peter Anvin
2010-10-26 20:27           ` Andi Kleen
2010-10-26 20:37             ` H. Peter Anvin
2010-10-27 10:50               ` Avi Kivity
2010-10-27 17:00                 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).