public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch] tsc-disable_A5
@ 2002-06-14 18:35 john stultz
  2002-06-14 18:53 ` Benjamin LaHaise
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: john stultz @ 2002-06-14 18:35 UTC (permalink / raw)
  To: marcelo; +Cc: lkml, Martin J. Bligh

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

Hey Marcelo,
	I know its probably poor form to send this out so close to -rc, but I
figured I might as well give it a shot. I'll happily resubmit this for
the .20pre series later if you'd prefer.

This patch disables the TSCs when compiled for Multiquad NUMA hardware.
Due to the slower interconnect, the TSCs aren't being synced properly at
boot time. Even if they were synced, since the different nodes are
driven by different crystals, the TSCs still drift. 

This results in sequential calls to gettimeofday to return
non-sequential time values. By disabling the TSCs on these boxes, it
forces gettimeofday to use the PIC clock instead, fixing the problem. 

Let me know if you have any comments. 

Thanks
-john

[-- Attachment #2: linux-2.4.19-pre10_tsc-disable_A5.patch --]
[-- Type: text/x-patch, Size: 4483 bytes --]

diff -Nru a/arch/i386/config.in b/arch/i386/config.in
--- a/arch/i386/config.in	Thu Jun 13 20:01:09 2002
+++ b/arch/i386/config.in	Thu Jun 13 20:01:09 2002
@@ -198,7 +198,17 @@
       define_bool CONFIG_X86_IO_APIC y
    fi
 else
-   bool 'Multiquad NUMA system' CONFIG_MULTIQUAD
+	bool 'Multiquad NUMA support' CONFIG_X86_NUMA
+	if [ "$CONFIG_X86_NUMA" = "y" ]; then
+		choice 'NUMA Hardware Selection' \
+		"NUMAQ					CONFIG_X86_NUMAQ \
+		 x440					CONFIG_X86_X440" NUMAQ
+		if [ "$CONFIG_X86_NUMAQ" = "y" ]; then
+			define_bool CONFIG_MULTIQUAD y
+		fi
+		# Multiquad NUMA boxes can't keep their TSCs in sync
+		define_bool CONFIG_TSC_DISABLE y
+	fi
 fi
 
 if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then
diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
--- a/arch/i386/kernel/setup.c	Thu Jun 13 20:01:09 2002
+++ b/arch/i386/kernel/setup.c	Thu Jun 13 20:01:09 2002
@@ -1127,8 +1127,12 @@
 __setup("cachesize=", cachesize_setup);
 
 
-#ifndef CONFIG_X86_TSC
+#if !defined(CONFIG_X86_TSC)||defined(CONFIG_TSC_DISABLE)
+#ifdef CONFIG_TSC_DISABLE
+static int tsc_disable __initdata = 1;	
+#else /*CONFIG_TSC_DISABLE*/
 static int tsc_disable __initdata = 0;
+#endif /*CONFIG_TSC_DISABLE*/
 
 static int __init tsc_setup(char *str)
 {
@@ -2733,7 +2737,7 @@
 	 */
 
 	/* TSC disabled? */
-#ifndef CONFIG_X86_TSC
+#if !defined(CONFIG_X86_TSC)||defined(CONFIG_TSC_DISABLE)
 	if ( tsc_disable )
 		clear_bit(X86_FEATURE_TSC, &c->x86_capability);
 #endif
@@ -2978,7 +2982,7 @@
 
 	if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
 		clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
-#ifndef CONFIG_X86_TSC
+#if !defined(CONFIG_X86_TSC)||defined(CONFIG_TSC_DISABLE)
 	if (tsc_disable && cpu_has_tsc) {
 		printk(KERN_NOTICE "Disabling TSC...\n");
 		/**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	Thu Jun 13 20:01:09 2002
+++ b/arch/i386/kernel/time.c	Thu Jun 13 20:01:09 2002
@@ -118,7 +118,7 @@
 
 extern spinlock_t i8259A_lock;
 
-#ifndef CONFIG_X86_TSC
+#if !defined(CONFIG_X86_TSC)||defined(CONFIG_TSC_DISABLE)
 
 /* This function must be called with interrupts disabled 
  * It was inspired by Steve McCanne's microtime-i386 for BSD.  -- jrs
diff -Nru a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
--- a/include/asm-i386/bugs.h	Thu Jun 13 20:01:09 2002
+++ b/include/asm-i386/bugs.h	Thu Jun 13 20:01:09 2002
@@ -173,7 +173,7 @@
 /*
  * If we configured ourselves for a TSC, we'd better have one!
  */
-#ifdef CONFIG_X86_TSC
+#if defined(CONFIG_X86_TSC)&&!defined(CONFIG_TSC_DISABLE)
 	if (!cpu_has_tsc)
 		panic("Kernel compiled for Pentium+, requires TSC feature!");
 #endif
diff -Nru a/include/asm-i386/timex.h b/include/asm-i386/timex.h
--- a/include/asm-i386/timex.h	Thu Jun 13 20:01:09 2002
+++ b/include/asm-i386/timex.h	Thu Jun 13 20:01:09 2002
@@ -40,7 +40,7 @@
 
 static inline cycles_t get_cycles (void)
 {
-#ifndef CONFIG_X86_TSC
+#if !defined(CONFIG_X86_TSC) || defined(CONFIG_TSC_DISABLE)
 	return 0;
 #else
 	unsigned long long ret;
diff -Nru a/include/net/pkt_sched.h b/include/net/pkt_sched.h
--- a/include/net/pkt_sched.h	Thu Jun 13 20:01:09 2002
+++ b/include/net/pkt_sched.h	Thu Jun 13 20:01:09 2002
@@ -12,7 +12,7 @@
 #include <linux/pkt_sched.h>
 #include <net/pkt_cls.h>
 
-#ifdef CONFIG_X86_TSC
+#if defined(CONFIG_X86_TSC)&&!defined(CONFIG_TSC_DISABLE)
 #include <asm/msr.h>
 #endif
 
@@ -253,7 +253,7 @@
 
 #define PSCHED_US2JIFFIE(delay) (((delay)+psched_clock_per_hz-1)/psched_clock_per_hz)
 
-#ifdef CONFIG_X86_TSC
+#if defined(CONFIG_X86_TSC)&&!defined(CONFIG_TSC_DISABLE)
 
 #define PSCHED_GET_TIME(stamp) \
 ({ u64 __cur; \
diff -Nru a/include/net/profile.h b/include/net/profile.h
--- a/include/net/profile.h	Thu Jun 13 20:01:09 2002
+++ b/include/net/profile.h	Thu Jun 13 20:01:09 2002
@@ -9,7 +9,7 @@
 #include <linux/kernel.h>
 #include <asm/system.h>
 
-#ifdef CONFIG_X86_TSC
+#if defined(CONFIG_X86_TSC) && !defined(CONFIG_TSC_DISABLE)
 #include <asm/msr.h>
 #endif
 
@@ -29,7 +29,7 @@
 extern struct timeval net_profile_adjust;
 extern void net_profile_irq_adjust(struct timeval *entered, struct timeval* leaved);
 
-#ifdef CONFIG_X86_TSC
+#if defined(CONFIG_X86_TSC)&&!defined(CONFIG_TSC_DISABLE)
 
 static inline void  net_profile_stamp(struct timeval *pstamp)
 {

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [Patch] tsc-disable_A5
@ 2002-06-14 21:53 Mikael Pettersson
  2002-06-14 22:11 ` john stultz
  0 siblings, 1 reply; 14+ messages in thread
From: Mikael Pettersson @ 2002-06-14 21:53 UTC (permalink / raw)
  To: davej, johnstul; +Cc: Martin.Bligh, linux-kernel, marcelo

On Fri, 14 Jun 2002 21:56:54 +0200, Dave Jones wrote:
>On Fri, Jun 14, 2002 at 12:04:18PM -0700, john stultz wrote:
>
> > .config that looked like:
> > 
> > CONFIG_X86_TSC=y
> > ...
> > # CONFIG_X86_TSC is not set
> > So I assumed CONFIG_X86_TSC would still hold. Am I wrong, or is there
> > another way to do this?
>
>Ugh, I hadn't realised the .config generation was so primitive.
>That's quite unfortunate. That needs fixing at some point.

Unless my memory is failing me, I believe the simplest approach
is to (1) don't set CONFIG_X86_TSC, and (2) pass "notsc" as a
kernel boot parameter.

CONFIG_X86_TSC means "the machine has working TSC, period".
That's an intensional optimisation.

Without CONFIG_X86_TSC, Linux manages without TSC, but will
detect and use it if it's there.

Finally, the "notsc" kernel parameter is for obscure cases
where the TSC is present, but should not be used for whatever
reason. I guess the present issue qualifies...

/Mikael

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [Patch] tsc-disable_A5
@ 2002-06-15 14:13 Mikael Pettersson
  2002-06-19 13:58 ` Maciej W. Rozycki
  0 siblings, 1 reply; 14+ messages in thread
From: Mikael Pettersson @ 2002-06-15 14:13 UTC (permalink / raw)
  To: johnstul, kai; +Cc: Martin.Bligh, davej, linux-kernel, marcelo

On 14 Jun 2002 16:44:30 -0700, john stultz wrote:
>On Fri, 2002-06-14 at 16:29, Kai Germaschewski wrote:
>> I suppose you could it rewrite like
>> 
>> ...
>> CONFIG_X86_WANT_TSC=y (or whatever)
>> ...
>> 
>> if [ some_condition ]; then
>>   define_bool CONFIG_X86_TSC n
>> else
>>   define_bool CONFIG_X86_TSC $CONFIG_X86_WANT_TSC
>> fi
>> 
>> Not exactly elegant, but it should work ;)
>
>Yep, my first release was done in a similar fashion, but Alan suggested
>the patch take on its current form. There may be cases where we want to
>know if we have a TSC even if we don't want to use them. 
>
>Thread link:
>http://www.uwsg.iu.edu/hypermail/linux/kernel/0205.3/1188.html

I disagree with Alan's recommendation.
The real problem is that the kernel confuses a CPU-level property
(do the CPUs have TSCs?) with a system-level property (are the
TSCs present and in sync?). CONFIG_X86_TSC really describes the
latter property, for the former we have the cpu_has_tsc() macro.

IMO, Kai is right and a nicer fix is to change arch/i386/config.in to:
- s/CONFIG_X86_TSC=y/CONFIG_X86_CPU_HAS_TSC=y/
  (this one can also be used as an optimisation to avoid runtime
  cpu_has_tsc() checks)
- append a rule which derives CONFIG_X86_TSC from CONFIG_X86_CPU_HAS_TSC
  and !multiquad

The other patch which adds an anti-CONFIG_X86_TSC to cancel the
first CONFIG_X86_TSC is so horribly hacky...

/Mikael

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

end of thread, other threads:[~2002-06-24 14:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-14 18:35 [Patch] tsc-disable_A5 john stultz
2002-06-14 18:53 ` Benjamin LaHaise
2002-06-18  0:48   ` Kurt Garloff
2002-06-18  1:31     ` john stultz
2002-06-14 18:57 ` Dave Jones
2002-06-14 19:04   ` john stultz
2002-06-14 19:56     ` Dave Jones
2002-06-14 23:29       ` Kai Germaschewski
2002-06-14 23:44         ` john stultz
2002-06-24  2:09 ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2002-06-14 21:53 Mikael Pettersson
2002-06-14 22:11 ` john stultz
2002-06-15 14:13 Mikael Pettersson
2002-06-19 13:58 ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox