LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* More breakage in native_rdtsc out of line in git-x86
@ 2008-01-09  3:55 Andi Kleen
  2008-01-09  5:21 ` More breakage in native_rdtsc out of line in git-x86 II Andi Kleen
  2008-01-09  9:09 ` More breakage in native_rdtsc out of line in git-x86 Ingo Molnar
  0 siblings, 2 replies; 18+ messages in thread
From: Andi Kleen @ 2008-01-09  3:55 UTC (permalink / raw)
  To: mingo, tglx, linux-kernel


I had some boot failures here with git-x86 with init and hotplug all 
segfaulting early on userland with new glibc.  Bisecting found

commit 6aea5bc37fa790eaf3a942f0785985914568e214
Author: Ingo Molnar <mingo@elte.hu>
Date:   Sat Jan 5 13:27:08 2008 +0100

    x86: move native_read_tsc() offline
    
    move native_read_tsc() offline.

I think the problem is that the vsyscall/vdso code calls it through
vread and for that it has to be exported. There seems to be also
another bug with the old style vsyscalls not using the TSC vread
that masks it on older glibc

Stepping with gdb through old style vgettimeofday() confirms that RDTSC is 
not used.

A long time ago we had a similar problem once and it was because of a 
problem exporting the vsyscall variables in vmlinux.lds.S -- looks like that 
has reappeared.

I think the new glibc shows it because it uses the vDSO not 
the older vsyscall and the new vDSO probably still works. Anyways haven't 
investigated why that is in detail yet, but that's a separate 
regression.

Back to the boot failure:

Unfortunately simply adding __vsyscall_fn to native_read_tsc doesn't 
work -- causes early kernel faults like

PANIC: early exception rip ffffffffff600105 error 10 cr2 ffffffffff600105
Pid: 0, comm: swapper Not tainted 2.6.24-rc6 #58

Call Trace:
 [<ffffffff80211dec>] native_sched_clock+0x9/0x3f
 [<ffffffff8022b758>] init_idle+0x33/0xd1
 [<ffffffff80825449>] sched_init+0x26d/0x283
 [<ffffffff80815899>] start_kernel+0x10b/0x2bd
 [<ffffffff80815114>] _sinittext+0x114/0x11b

Not sure why that is -- in theory the vsyscall functions should be callable 
from the main kernel. Might be a binutils problem or another code
regression.

Anyways it looks like the only good fix is to either revert that or
fork into two functions one for vread() and another for normal tsc ->read()

This is all in addition to the problem of it having incorrect barriers.
I note that my original patch didn't have any of these problems.

I'm using the appended revert patch here as a workaround for now.

-Andi


Revert rdtsc out of line change

Reverts 

commit 6aea5bc37fa790eaf3a942f0785985914568e214
Author: Ingo Molnar <mingo@elte.hu>
Date:   Sat Jan 5 13:27:08 2008 +0100

    x86: move native_read_tsc() offline

    move native_read_tsc() offline.

The function is called by vsyscalls in ring 3, so it can't be out of line this way.

Signed-off-by: Andi Kleen <ak@suse.de>

Index: linux/arch/x86/kernel/rtc.c
===================================================================
--- linux.orig/arch/x86/kernel/rtc.c
+++ linux/arch/x86/kernel/rtc.c
@@ -194,14 +194,3 @@ int update_persistent_clock(struct times
 {
 	return set_rtc_mmss(now.tv_sec);
 }
-
-unsigned long long native_read_tsc(void)
-{
-	DECLARE_ARGS(val, low, high);
-
-	asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
-	rdtsc_barrier();
-
-	return EAX_EDX_VAL(val, low, high);
-}
-
Index: linux/include/asm-x86/msr.h
===================================================================
--- linux.orig/include/asm-x86/msr.h
+++ linux/include/asm-x86/msr.h
@@ -91,7 +91,13 @@ static inline int native_write_msr_safe(
 	return err;
 }
 
-extern unsigned long long native_read_tsc(void);
+static inline unsigned long long native_read_tsc(void)
+{
+	DECLARE_ARGS(val, low, high);
+
+	asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
+	return EAX_EDX_VAL(val, low, high);
+}
 
 static inline unsigned long long native_read_pmc(int counter)
 {



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

end of thread, other threads:[~2008-01-11  5:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-09  3:55 More breakage in native_rdtsc out of line in git-x86 Andi Kleen
2008-01-09  5:21 ` More breakage in native_rdtsc out of line in git-x86 II Andi Kleen
2008-01-09  9:09 ` More breakage in native_rdtsc out of line in git-x86 Ingo Molnar
2008-01-09 14:19   ` Andi Kleen
2008-01-09 15:22     ` Ingo Molnar
2008-01-09 15:51       ` Andi Kleen
2008-01-09 16:30         ` Ingo Molnar
2008-01-09 17:48           ` Andi Kleen
2008-01-09 20:25             ` Arjan van de Ven
2008-01-09 20:40               ` Andi Kleen
2008-01-09 20:57                 ` H. Peter Anvin
2008-01-09 22:09             ` Björn Steinbrink
2008-01-09 22:28               ` Andi Kleen
2008-01-09 22:35                 ` Harvey Harrison
2008-01-09 22:41                   ` Andi Kleen
2008-01-09 23:21                     ` Björn Steinbrink
2008-01-09 23:37                     ` Paolo Ciarrocchi
2008-01-11  5:21                       ` Cyrill Gorcunov

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