[PATCH] [3/45] x86: Separate checking of unsynchronized and unstable TSC

From: Andi Kleen
Date: Fri Sep 21 2007 - 16:46:06 EST



Preparationary patch for the new sched/printk_clock()

Signed-off-by: Andi Kleen <ak@xxxxxxx>

---
arch/i386/kernel/tsc.c | 9 ++++-----
arch/x86_64/kernel/tsc.c | 5 +----
2 files changed, 5 insertions(+), 9 deletions(-)

Index: linux/arch/i386/kernel/tsc.c
===================================================================
--- linux.orig/arch/i386/kernel/tsc.c
+++ linux/arch/i386/kernel/tsc.c
@@ -332,7 +332,7 @@ static struct dmi_system_id __initdata b
*/
__cpuinit int unsynchronized_tsc(void)
{
- if (!cpu_has_tsc || tsc_unstable)
+ if (!cpu_has_tsc)
return 1;
/*
* Intel systems are normally all synchronized.
@@ -341,9 +341,9 @@ __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;
}

/*
@@ -387,13 +387,12 @@ void __init tsc_init(void)
/* Check and install the TSC clocksource */
dmi_check_system(bad_tsc_dmi_table);

- unsynchronized_tsc();
check_geode_tsc_reliable();
current_tsc_khz = tsc_khz;
clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz,
clocksource_tsc.shift);
/* lower the rating if we already know its unstable: */
- if (check_tsc_unstable()) {
+ if (check_tsc_unstable() || unsynchronized_tsc()) {
clocksource_tsc.rating = 0;
clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
} else
Index: linux/arch/x86_64/kernel/tsc.c
===================================================================
--- linux.orig/arch/x86_64/kernel/tsc.c
+++ linux/arch/x86_64/kernel/tsc.c
@@ -124,9 +124,6 @@ core_initcall(cpufreq_tsc);
*/
__cpuinit int unsynchronized_tsc(void)
{
- if (tsc_unstable)
- return 1;
-
#ifdef CONFIG_SMP
if (apic_is_clustered_box())
return 1;
@@ -199,7 +196,7 @@ void __init init_tsc_clocksource(void)
if (!notsc) {
clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
clocksource_tsc.shift);
- if (check_tsc_unstable())
+ if (unsynchronized_tsc() || check_tsc_unstable())
clocksource_tsc.rating = 0;

clocksource_register(&clocksource_tsc);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/