Rgeression: 2.6.30-rc6-git3 build error - ICE from drivers/char/random.c
CC Maintainer.
----- Original Message ----
Quoted 37 lines
From: Martin Knoblauch <[email protected]>
To: [email protected]
Sent: Monday, May 18, 2009 2:58:35 PM
Subject: Rgeression: 2.6.30-rc6-git3 build error - ICE fromdrivers/char/random.cHi,
trying to build 2.6.30-rc6-git3 with RHEL4.3 userspace (gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)):
CC
drivers/char/mem.o
CCdrivers/char/random.odrivers/char/random.c: In function `get_random_int':drivers/char/random.c:1672: error: unrecognizable insn:
(insn 202 148 150 0 /scratch/build/linux-2.6.30-rc6-git3/arch/x86/include/asm/tsc.h:23 (set (reg:SI 0 ax [91])(subreg:SI (plus:DI (plus:DI (reg:DI 0 ax [88]) (subreg:DI (reg:SI 6 bp) 0)) (const_int -4 [0xfffffffffffffffc])) 0)) -1 (nil) (nil))
drivers/char/random.c:1672: internal compiler error: inextract_insn, at recog.c:2083
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
Preprocessed source stored into/tmp/ccvLBDQc.outfile, please attach this to your bugreport.
make[2]: *** [drivers/char/random.o] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2did not happen with -rc3. Config attached.
Cheers
Martin
Quoted 2 lines · Martin Knoblauch
CC Maintainer.
Bizarre. I bet Linus has an opinion about your compiler.
Quoted 38 lines
----- Original Message ----
Quoted 37 lines
From: Martin Knoblauch <[email protected]>
To: [email protected]
Sent: Monday, May 18, 2009 2:58:35 PM
Subject: Rgeression: 2.6.30-rc6-git3 build error - ICE fromdrivers/char/random.cHi,
trying to build 2.6.30-rc6-git3 with RHEL4.3 userspace (gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)):
CC
drivers/char/mem.o
CCdrivers/char/random.odrivers/char/random.c: In function `get_random_int':drivers/char/random.c:1672: error: unrecognizable insn:
(insn 202 148 150 0 /scratch/build/linux-2.6.30-rc6-git3/arch/x86/include/asm/tsc.h:23 (set (reg:SI 0 ax [91])(subreg:SI (plus:DI (plus:DI (reg:DI 0 ax [88]) (subreg:DI (reg:SI 6 bp) 0)) (const_int -4 [0xfffffffffffffffc])) 0)) -1 (nil) (nil))
drivers/char/random.c:1672: internal compiler error: inextract_insn, at recog.c:2083
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
Preprocessed source stored into/tmp/ccvLBDQc.outfile, please attach this to your bugreport.
make[2]: *** [drivers/char/random.o] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2did not happen with -rc3. Config attached.
Cheers
Martin
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 5 lines · Matt Mackall
Quoted 2 lines · Martin Knoblauch
CC Maintainer.
Bizarre. I bet Linus has an opinion about your compiler.
I have opinions about a lot of things ;)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/char/random.c: In function `get_random_int':drivers/char/random.c:1672: error: unrecognizable insn:
(insn 202 148 150 0 /scratch/build/linux-2.6.30-rc6-git3/arch/x86/include/asm/tsc.h:23 (set (reg:SI 0 ax [91])(subreg:SI (plus:DI (plus:DI (reg:DI 0 ax [88]) (subreg:DI (reg:SI 6 bp) 0)) (const_int -4 [0xfffffffffffffffc])) 0)) -1 (nil) (nil))
drivers/char/random.c:1672: internal compiler error: inextract_insn, at recog.c:2083
Oh wow. We seldom hit these things. Internal gcc compiler errors do happen, but it tends to be _very_ rare. And it's almost always some subtle use of inline asm that gets gcc's knickers all twisted up. Often due to the double register usage of 64-bit long long arithmetic.
That error report seems to be a bit confused about exactly what triggered
it: it points to both "get_cycles()" (arch/x86/include/asm/tsc.h:23) and to the get_cpu_var() asm code (drivers/char/random.c:1672).
Martin - Is this a 32-bit compile? In particular, does the problem go away if you remove the " + get_cycles() " part (which is three lines down from what that error case reports, but with code movement and combining, who can tell which one it is?)
Usually the only way to get gcc to calm down when it gets into a tizzy like this is to rewrite the thing in some way that gcc has a harder time screwing up. In particular, asking gcc to handle a 64-bit value (inside get_cycles()) while it's busy doing a lot of other things may have just fused the compilers poor little brain.
So the fix _may_ be as simple as just something like the appended. It doesn't change anything, but it rewrites things so that it doesn't do that "rdtsc" while a lot of other things are also "in flight" at the same time.
Linus
--- drivers/char/random.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/char/random.c +5 -2
@@ -1669,11 +1669,14 @@ DEFINE_PER_CPU(__u32 [4], get_random_int_hash);unsigned int get_random_int (void ) {struct keydata *keyptr; -__u32 *hash =get_cpu_var (get_random_int_hash); +__u32 *hash, garbage;int ret; + garbage =get_cycles () + (long )&ret; + hash =get_cpu_var (get_random_int_hash); + keyptr =get_keyptr (); - hash[0 ] += current->pid + jiffies +get_cycles () + (int )(long )&ret; + hash[0 ] += current->pid + jiffies + garbage; ret =half_md4_transform (hash, keyptr->secret);put_cpu_var (get_random_int_hash);
----- Original Message ----
Quoted 10 lines
From: Linus Torvalds <[email protected]>
To: Matt Mackall <[email protected]>; Ingo Molnar <[email protected]>
Cc: Martin Knoblauch <[email protected]>; Linux Kernel Mailing List <[email protected]>
Sent: Tuesday, May 19, 2009 12:29:22 AM
Subject: Re: Rgeression: 2.6.30-rc6-git3 build error - ICE fromdrivers/char/random.cOn Mon, 18 May 2009, Matt Mackall wrote:
Quoted 8 lines
Quoted 5 lines · Martin Knoblauch
Quoted 2 lines
CC Maintainer.
Bizarre. I bet Linus has an opinion about your compiler.
I have opinions about a lot of things ;)
who hasn't :-)
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/char/random.c: In function `get_random_int':drivers/char/random.c:1672: error: unrecognizable insn:
(insn 202 148 150 0/scratch/build/linux-2.6.30-rc6-git3/arch/x86/include/asm/tsc.h:23 (set (reg:SI 0 ax [91])
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
(subreg:SI (plus:DI (plus:DI (reg:DI 0 ax [88]) (subreg:DI (reg:SI 6 bp) 0)) (const_int -4 [0xfffffffffffffffc])) 0)) -1 (nil) (nil))
drivers/char/random.c:1672: internal compiler error: inextract_insn, atrecog.c:2083
Oh wow. We seldom hit these things. Internal gcc compiler errors do happen, but it tends to be _very_ rare. And it's almost always some subtle use of inline asm that gets gcc's knickers all twisted up. Often due to the double register usage of 64-bit long long arithmetic.
Quoted 9 lines
That error report seems to be a bit confused about exactly what triggered
it: it points to both "get_cycles()" (arch/x86/include/asm/tsc.h:23) and to theget_cpu_var()asm code (drivers/char/random.c:1672).Martin - Is this a 32-bit compile? In particular, does the problem go away if you remove the " +
get_cycles()" part (which is three lines down from what that error case reports, but with code movement and combining, who can tell which one it is?)
sorry, if I was unclear. 64-bit build.
Quoted 27 lines
Usually the only way to get gcc to calm down when it gets into a tizzy like this is to rewrite the thing in some way that gcc has a harder time screwing up. In particular, asking gcc to handle a 64-bit value (inside
get_cycles()) while it's busy doing a lot of other things may have just fused the compilers poor little brain.So the fix _may_ be as simple as just something like the appended. It doesn't change anything, but it rewrites things so that it doesn't do that "rdtsc" while a lot of other things are also "in flight" at the same time.
Linus
---
drivers/char/random.c| 7 +++++--1 files changed, 5 insertions(+), 2 deletions(-)drivers/char/random.c +1
-1@@ -1669,11 +1669,14 @@ DEFINE_PER_CPU(__u32 [4], get_random_int_hash);unsigned int get_random_int (void ) {struct keydata *keyptr; -__u32 *hash =get_cpu_var (get_random_int_hash); +__u32 *hash, garbage;int ret;
drivers/char/random.c DEFINE_PER_CPU(__u32 [4], get_random_int_hash); · line 1682
Quoted 10 lines
drivers/char/random.c +4
-1+ garbage =get_cycles () + (long )&ret; + hash =get_cpu_var (get_random_int_hash); + keyptr =get_keyptr (); - hash[0 ] += current->pid + jiffies +get_cycles () + (int )(long )&ret; + hash[0 ] += current->pid + jiffies + garbage; ret =half_md4_transform (hash, keyptr->secret);put_cpu_var (get_random_int_hash);
With your patch, the problem still remains. Line 1685 is the end of the patched routine now.
[root@lpsdm52 linux-2.6.30-rc6-git3]# make CONFIG_DEBUG_SECTION_MISMATCH=y
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
CALL scripts/checksyscalls.sh
CHK include/linux/compile.h
CC drivers/char/random.o
drivers/char/random.c: In function `get_random_int':
drivers/char/random.c:1685: error: unrecognizable insn:
(insn 202 44 46 0 /scratch/build/linux-2.6.30-rc6-git3/arch/x86/include/asm/tsc.h:23 (set (reg:SI 2 cx [72])
(subreg:SI (plus:DI (subreg:DI (reg:SI 6 bp) 0)
(const_int -4 [0xfffffffffffffffc])) 0)) -1 (nil)
(nil))drivers/char/random.c:1685: internal compiler error: in extract_insn, at recog.c:2083 Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccFsBjvb.out file, please attach this to your bugreport. make[2]: *** [drivers/char/random.o] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2
Cheers
Martin
Quoted 2 lines · Martin Knoblauch
With your patch, the problem still remains. Line 1685 is the end of the patched routine now.
Ok, so can you do two other simple tests:
- just remove the "+ (long)&ret" entirely.
Now, usually gcc doesn't have issues with non-asm things, but that's an odd way of getting the current stack address by lookin gat the address of a variable that hasn't even been used, so maybe it triggers some untested codepath in gcc (and thus the bug).
- if that doesn't make a difference, then remove the "get_cycles() +" part instead.
The fact that "arch/x86/include/asm/tsc.h:23" is mentioned in the insn dump does make it look like get_cycles(), but on the other hand I'd have actually expected it to be "arch/x86/include/asm/msr.h:112", because that is the location of the actual asm statement.
Just to see which part of it gcc has issues with.
Linus
----- Original Message ----
Quoted 13 lines
From: Linus Torvalds <[email protected]>
To: Martin Knoblauch <[email protected]>
Cc: Matt Mackall <[email protected]>; Ingo Molnar <[email protected]>; Linux Kernel Mailing List <[email protected]>
Sent: Tuesday, May 19, 2009 5:09:40 PM
Subject: Re: Rgeression: 2.6.30-rc6-git3 build error - ICE fromdrivers/char/random.cQuoted 2 lines · Martin Knoblauch
With your patch, the problem still remains. Line 1685 is the end of the
patched routine now.
Quoted 9 lines
Ok, so can you do two other simple tests:
- just remove the "+ (long)&ret" entirely.
Now, usually gcc doesn't have issues with non-asm things, but that's an odd way of getting the current stack address by lookin gat the address of a variable that hasn't even been used, so maybe it triggers some untested codepath in gcc (and thus the bug).
Removing above fixes the ICE. It does so in both the original and the patched version.
Removing get_cycles() has no effect wrt. the ICE.
Cheers
Martin
Quoted 11 lines · Martin Knoblauch
Quoted 10 lines
Ok, so can you do two other simple tests:
- just remove the "+ (long)&ret" entirely.
Now, usually gcc doesn't have issues with non-asm things, but that's an odd way of getting the current stack address by lookin gat the address of a variable that hasn't even been used, so maybe it triggers some untested codepath in gcc (and thus the bug).
Quoted 3 lines
Removing above fixes the ICE. It does so in both the original and the patched version.
Removing
get_cycles()has no effect wrt. the ICE.
Oh wow. Ok, I suggested it, but I have to admit that I didn't really think that it would be the &ret thing.
Very interesting fragility in your gcc version.
Anyway, that part of the garbage is much less interesting than the cycle counter (the stack pointer will be the same for the same process and callchain anyway - and 'current->pid' is already gives difference answers for different processes), so I'll just remove it.
We could replace it with something like __builtin_frame_address(0) or whatever, but I don't know which gcc version _that_ was introduced in, so I suspect I should just get rid of it as not being worth it.
I guess getting rid of 'jiffies' is also worth it. Even at its very worst, 'get_cycles()' should return jiffy-level information, so adding in jiffies doesn't add anything to it.
So I'll just commit this. But I'd like to have a final "tested-by" from you, since I don't have access to your version of gcc on any of my machines.
Linus
--- drivers/char/random.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/random.c +1 -1
@@ -1673,7 +1673,7 @@ unsigned int get_random_int(void)int ret; keyptr =get_keyptr (); - hash[0 ] += current->pid + jiffies +get_cycles () + (int )(long )&ret; + hash[0 ] += current->pid +get_cycles (); ret =half_md4_transform (hash, keyptr->secret);put_cpu_var (get_random_int_hash);
Quoted 4 lines · Linus Torvalds
I guess getting rid of 'jiffies' is also worth it. Even at its very worst, '
get_cycles()' should return jiffy-level information, so adding in jiffies doesn't add anything to it.
I take that back. If there isno TSC at all, "get_cycles()" might just be returning zero. So the jiffies fallback is probably better than nothing.
So I'll just remove the (long)&ret part. And you already said that that fixed it both with my previous patch and without, so I guess it's already tested.
Linus
Martin Knoblauch
Tested-by----- Original Message ----
Quoted 14 lines
From: Linus Torvalds <[email protected]>
To: Martin Knoblauch <[email protected]>
Cc: Matt Mackall <[email protected]>; Ingo Molnar <[email protected]>; Linux Kernel Mailing List <[email protected]>
Sent: Tuesday, May 19, 2009 8:24:48 PM
Subject: Re: Rgeression: 2.6.30-rc6-git3 build error - ICE fromdrivers/char/random.cQuoted 4 lines · Linus Torvalds
I guess getting rid of 'jiffies' is also worth it. Even at its very worst, '
get_cycles()' should return jiffy-level information, so adding in jiffies doesn't add anything to it.
Quoted 8 lines
I take that back. If there isno TSC at all, "
get_cycles()" might just be returning zero. So the jiffies fallback is probably better than nothing.So I'll just remove the (long)&ret part. And you already said that that fixed it both with my previous patch and without, so I guess it's already tested.
Linus
correct. The original code with (long)&ret removed yields:
hash[0] += current->pid + jiffies + get_cycles();
and compiles OK.
Cheers
Martin
Quoted 11 lines · Linus Torvalds
Quoted 4 lines · Linus Torvalds
I guess getting rid of 'jiffies' is also worth it. Even at its very worst, '
get_cycles()' should return jiffy-level information, so adding in jiffies doesn't add anything to it.I take that back. If there isno TSC at all, "
get_cycles()" might just be returning zero. So the jiffies fallback is probably better than nothing.So I'll just remove the (long)&ret part. [...]
I suspect we could add current_thread_info() or 'current' to it - as they are initialized variables. (which the stack pointer mostly boils down to - the stack depth is predictable)
Not worth the trouble though i suspect.
Ingo