Skip to contentSkip to conversation

x86_64: On Intel systems when CPU has C3 don't use TSC

PATCH In review Andi Kleen 2 participants 7 messages Jul 29, 2006 – Aug 1, 2006 1 message not in the archive

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 2/8 x86_64: On Intel systems when CPU has C3 don't use TSC

On Intel systems generally the TSC stops in C3 or deeper, so don't use it there. Follows similar logic on i386.

This should fix problems on Meroms.

---
 arch/x86_64/kernel/time.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
arch/x86_64/kernel/time.c +12 -4
Index: linux-2.6.18-rc2-git7/arch/x86_64/kernel/time.c
===================================================================
@@ -28,6 +28,7 @@
 #include <linux/acpi.h>
 #ifdef CONFIG_ACPI
 #include <acpi/achware.h>	/* for PM timer frequency */
+#include <acpi/acpi_bus.h>
 #endif
 #include <asm/8253pit.h>
 #include <asm/pgtable.h>
@@ -953,11 +954,18 @@ __cpuinit int unsynchronized_tsc(void)
 #ifdef CONFIG_SMP
 	if (apic_is_clustered_box())
 		return 1;
- 	/* Intel systems are normally all synchronized. Exceptions
- 	   are handled in the check above. */
- 	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
- 		return 0;
 #endif
+	/* Most intel systems have synchronized TSCs except for
+	   multi node systems */
+ 	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
+#ifdef CONFIG_ACPI
+		/* But TSC doesn't tick in C3 so don't use it there */
+		if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 100)
+			return 1;
+#endif
+ 		return 0;
+	}
+
  	/* Assume multi socket systems are not synchronized */
  	return num_present_cpus() > 1;
 }
#1 lore raw
Quoted 7 lines · Andi Kleen

On Intel systems generally the TSC stops in C3 or deeper, so don't use it there. Follows similar logic on i386.

This should fix problems on Meroms.

...

Quoted 4 lines
arch/x86_64/kernel/time.c +4 -0
+	/* Most intel systems have synchronized TSCs except for
+	   multi node systems */
+ 	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
+#ifdef CONFIG_ACPI

arch/x86_64/kernel/time.c __cpuinit int unsynchronized_tsc(void) · line 971

Quoted 10 lines
arch/x86_64/kernel/time.c +7 -0
+		/* But TSC doesn't tick in C3 so don't use it there */
+		if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 100)
+			return 1;
+#endif
+ 		return 0;
+	}
+
  	/* Assume multi socket systems are not synchronized */
  	return num_present_cpus() > 1;
 }

Hi,

I had some faith in this patch , but this just enable boot parameter notsc (which I already use). And "just" disable tsc don't solve all the problems.

After "Using ACPI (MADT) for SMP configuration information" my acpi_fadt.length is great than 0 acpi_fadt.plvl3_lat is 1001

On BIOS 1.40 update description of ASRock, claims this VIA chipset have C1 stepping support.

this is a Pentium Dual Core on a 775Dual-880Pro
http://www.asrock.com/product/775Dual-880Pro.htm
http://bugme.osdl.org/show_bug.cgi?id=6419

Thanks,
Sérgio M. B.

author
#2 lore raw
Quoted 4 lines

I had some faith in this patch , but this just enable boot parameter notsc (which I already use). And "just" disable tsc don't solve all the problems.

What problems do you have?

Quoted 5 lines

After "Using ACPI (MADT) for SMP configuration information" my acpi_fadt.length is great than 0 acpi_fadt.plvl3_lat is 1001

You don't have C3 support so the patch doesn't apply to you.

Quoted 2 lines

On BIOS 1.40 update description of ASRock, claims this VIA chipset have C1 stepping support.

C1 stepping is a processor revision; it has nothing to do with ACPI C* power states.

-Andi

#3 lore raw
Quoted 7 lines · Andi Kleen
Quoted 2 lines

I had some faith in this patch , but this just enable boot parameter notsc (which I already use). And "just" disable tsc don't solve all

the

Quoted 1 line

problems.

What problems do you have?

Hi Andi ,
if I boot without notsc , I have many lost timer tickets. if I boot with notsc , I have,at begging, a few lost timer ticket, and after some stress usb modem I got
uhci_hcd 0000:00:10.1: host controller process error, something bad happened!
uhci_hcd 0000:00:10.1: host controller halted, very bad! uhci_hcd 0000:00:10.1: HC died; cleaning up
usb 3-2: USB disconnect, address 2

Thanks for your reply

Signature · 1 line
Sérgio M. B.
author
#4 lore raw
Quoted 10 lines · Sergio Monteiro Basto
Quoted 7 lines · Andi Kleen
Quoted 2 lines

I had some faith in this patch , but this just enable boot parameter notsc (which I already use). And "just" disable tsc don't solve all

the

Quoted 1 line

problems.

What problems do you have?

Hi Andi ,
if I boot without notsc , I have many lost timer tickets.

Lost timer ticks print a rip. Do you have some samples?

Anyways, for a single socket Intel dual core TSCs should be definitely synced so I don't know what could be wrong on your system. Please post full boot.msg at least.

-Andi

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#6 lore raw
Quoted 2 lines · Sergio Monteiro Basto
Quoted 1 line · Andi Kleen

Lost timer ticks print a rip. Do you have some samples?

Can you send dmesg with the following patch applied too?

cc'ing Suresh because he might have an explanation too then.

-Andi

arch/x86_64/kernel/smpboot.c +1 -1
Index: linux-2.6.18-rc3-work/arch/x86_64/kernel/smpboot.c
===================================================================
@@ -345,7 +345,7 @@ static void __cpuinit tsc_sync_wait(void
 	 * mess up a possible perfect synchronization with a
 	 * not-quite-perfect algorithm.
 	 */
-	if (notscsync || !cpu_has_tsc || !unsynchronized_tsc())
+	if (0 && (notscsync || !cpu_has_tsc || !unsynchronized_tsc()))
 		return;
 	sync_tsc(0);
 }
#7 lore raw

ok , here it is dmesg version 16
I just add this printtk
--- linux-2.6.17.x86_64/arch/x86_64/kernel/time.c.orig 2006-08-01
01:34:29.000000000 +0100
+++ linux-2.6.17.x86_64/arch/x86_64/kernel/time.c 2006-08-01 23:31:29.000000000 +0100
@@ -959,6 +959,9 @@ __cpuinit int unsynchronized_tsc(void)
multi node systems */
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
#ifdef CONFIG_ACPI
+ printk(KERN_INFO "time.c:SB acpi_fadt.length=%d, acpi_fadt.plvl3_lat=%d unsynchronized_tsc=%d\n",
+ acpi_fadt.length, acpi_fadt.plvl3_lat,(acpi_fadt.length > 0 && acpi_fadt.plvl3_lat <
+ 100) );
/* But TSC doesn't tick in C3 so don't use it there */ if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 100)
return 1;

but this time the function unsynchronized_tsc was just call one time.

time.c:SB acpi_fadt.length=0, acpi_fadt.plvl3_lat=0 unsynchronized_tsc=0

The patch works like I have use boot parameter notsc, which is better. Now I don't need any parameter to boot.

Big Thanks

Quoted 23 lines · Andi Kleen
Quoted 2 lines · Sergio Monteiro Basto
Quoted 1 line · Andi Kleen

Lost timer ticks print a rip. Do you have some samples?

Can you send dmesg with the following patch applied too?

cc'ing Suresh because he might have an explanation too then.

-Andi

Index: linux-2.6.18-rc3-work/arch/x86_64/kernel/smpboot.c
===================================================================

arch/x86_64/kernel/smpboot.c +1 -1
@@ -345,7 +345,7 @@ static void __cpuinit tsc_sync_wait(void
 	 * mess up a possible perfect synchronization with a
 	 * not-quite-perfect algorithm.
 	 */
-	if (notscsync || !cpu_has_tsc || !unsynchronized_tsc())
+	if (0 && (notscsync || !cpu_has_tsc || !unsynchronized_tsc()))
 		return;
 	sync_tsc(0);
 }
Signature · 1 line
Sérgio M. B.