Skip to contentSkip to conversation

x86: avoid modifying global flag tsc_unstable in unsychronized_tsc()

PATCH In review Hillier, Gernot 2 participants 2 messages Oct 12, 2009 – Oct 13, 2009 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: avoid modifying global flag tsc_unstable in unsychronized_tsc()

From: Gernot Hillier <[email protected]>

The current behavior of unsynchronized_tsc() prevents the warning for unsychronized TSCs to be printed: tsc_init() calls unsynchronized_tsc() first to check for such problems; if found, mark_tsc_unstable() is called. However, the latter bails out immediately as unsynchronized_ tsc() did already set the global flag tsc_unstable. Thus, the intended warning message "Marking TSC unstable due to TSCs unsynchronized" won't show up.

This patch changes the behavior for unsynchronized_tsc() to only *check* for the quirk condition, but not to modify any global flags. If I'm not mistaken, the only place to *set* the flag shall be mark_tsc_unstable().

arch/x86/kernel/tsc.c +2 -2
index cd982f4..ffbb786 100644
@@ -836,10 +836,10 @@ __cpuinit int unsynchronized_tsc(void)
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
 		/* assume multi socket systems are not synchronized: */
 		if (num_possible_cpus() > 1)
-			tsc_unstable = 1;
+			return 1;
 	}
 
-	return tsc_unstable;
+	return 0;
 }
 
 static void __init init_tsc_clocksource(void)
#1 lore raw
Quoted 10 lines · Gernot

From: Gernot Hillier <[email protected]>

The current behavior of unsynchronized_tsc() prevents the warning for unsychronized TSCs to be printed: tsc_init() calls unsynchronized_tsc() first to check for such problems; if found, mark_tsc_unstable() is called. However, the latter bails out immediately as unsynchronized_ tsc() did already set the global flag tsc_unstable. Thus, the intended warning message "Marking TSC unstable due to TSCs unsynchronized" won't show up.

Quoted 3 lines

This patch changes the behavior for unsynchronized_tsc() to only *check* for the quirk condition, but not to modify any global flags. If I'm not mistaken, the only place to *set* the flag shall be mark_tsc_unstable().

Yes, you are right. The patch looks good to me.

Thanks,
Alok

Quoted 23 lines
arch/x86/kernel/tsc.c +2 -2
index cd982f4..ffbb786 100644
@@ -836,10 +836,10 @@ __cpuinit int unsynchronized_tsc(void)
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
 		/* assume multi socket systems are not synchronized: */
 		if (num_possible_cpus() > 1)
-			tsc_unstable = 1;
+			return 1;
 	}
 
-	return tsc_unstable;
+	return 0;
 }
 
 static void __init init_tsc_clocksource(void)