linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [FTF][PATCH] linux-2.4.20-pre5_bad-tsc_A0
@ 2002-08-29  1:20 john stultz
  2002-08-29  3:54 ` William Lee Irwin III
  0 siblings, 1 reply; 2+ messages in thread
From: john stultz @ 2002-08-29  1:20 UTC (permalink / raw)
  To: lkml; +Cc: Alan Cox, pavel, andrea, Mikael Pettersson, msw, Ulrich Drepper

FTF = Fan The Flames :)

Hi all, 
	Since there are some folks who felt this could still be useful as a
boot option, here is the "badtsc" half of my earlier tsc-disable patch.
Briefly, the patch keeps the kernel from using possibly unsynced TSCs
for gettimeofday calculations, while sill allowing userspace to read the
TSCs without warning. 

Personally, I've been swayed by Andrea that this isn't the proper
solution to keep user-space apps that blindly use the rdtsc instruction
from crashing when the TSCs are disabled. Instead I feel forcing apps
(and i686 compiled glibc, <nudge, nudge, Ulrich> ;) to check the CR4 for
availability is the proper solution. 

However, if one wants to still use the TSCs from userspace, for
statistical purposes only, with the understanding that values read may
not be sane, this patch will let them do so by passing "badtsc" as a
boot option. 

As long as folks still seem interested in this, I'll keep on maintaining
it, but if you feel it should just die, let me know.

thanks
-john


diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	Wed Aug 28 18:17:53 2002
+++ b/arch/i386/kernel/time.c	Wed Aug 28 18:17:53 2002
@@ -70,6 +70,9 @@
 /* Number of usecs that the last interrupt was delayed */
 static int delay_at_last_interrupt;
 
+/*boot option flag to keep gettimeofday from using do_fastgettimeoffset */
+static int  bad_tsc __initdata = 0;
+
 static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */
 
 /* Cached *multiplier* to convert TSC counts to microseconds.
@@ -637,6 +640,18 @@
 	return 0;
 }
 
+#ifndef CONFIG_X86_TSC
+/* badtsc boot option: Used to keep do_gettimeofday from 
+ * using do_fast_gettimeoffset()
+ */
+static int __init badtsc_setup(char *str)
+{
+	bad_tsc = 1;
+	return 1;
+}
+__setup("badtsc", badtsc_setup);
+#endif
+
 void __init time_init(void)
 {
 	extern int x86_udelay_tsc;
@@ -675,16 +690,17 @@
 		unsigned long tsc_quotient = calibrate_tsc();
 		if (tsc_quotient) {
 			fast_gettimeoffset_quotient = tsc_quotient;
-			use_tsc = 1;
 			/*
 			 *	We could be more selective here I suspect
 			 *	and just enable this for the next intel chips ?
 			 */
-			x86_udelay_tsc = 1;
+			if(!bad_tsc){
+				use_tsc = 1;
+				x86_udelay_tsc = 1;
 #ifndef do_gettimeoffset
-			do_gettimeoffset = do_fast_gettimeoffset;
+				do_gettimeoffset = do_fast_gettimeoffset;
 #endif
-
+			}
 			/* report CPU clock rate in Hz.
 			 * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
 			 * clock/second. Our precision is about 100 ppm.




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

* Re: [FTF][PATCH] linux-2.4.20-pre5_bad-tsc_A0
  2002-08-29  1:20 [FTF][PATCH] linux-2.4.20-pre5_bad-tsc_A0 john stultz
@ 2002-08-29  3:54 ` William Lee Irwin III
  0 siblings, 0 replies; 2+ messages in thread
From: William Lee Irwin III @ 2002-08-29  3:54 UTC (permalink / raw)
  To: john stultz
  Cc: lkml, Alan Cox, pavel, andrea, Mikael Pettersson, msw, Ulrich Drepper

On Wed, Aug 28, 2002 at 06:20:07PM -0700, john stultz wrote:
> As long as folks still seem interested in this, I'll keep on maintaining
> it, but if you feel it should just die, let me know.

Is there any chance you could do a 2.5.32 version that skips over
synchronize_tsc_ap() etc. entirely? synchronize_tsc_ap() appears to
oops on 32x NUMA-Q boxen (though it could be io_apic.c running amok).


Cheers,
Bill

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

end of thread, other threads:[~2002-08-29  3:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-29  1:20 [FTF][PATCH] linux-2.4.20-pre5_bad-tsc_A0 john stultz
2002-08-29  3:54 ` William Lee Irwin III

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