aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/tsc_64.c
diff options
context:
space:
mode:
authorAlok Kataria <akataria@vmware.com>2008-07-01 14:43:18 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-09 01:43:25 -0400
commit0ef95533326a7b37d16025af9edc0c18e644b346 (patch)
tree216e53f744b9bd718c4f54862032c241bf59fd73 /arch/x86/kernel/tsc_64.c
parent746f2eb790e75676ddc3b816ba18bac4179cc744 (diff)
x86: merge sched_clock handling
Move the basic global variable definitions and sched_clock handling in the common "tsc.c" file. - Unify notsc kernel command line handling for 32 bit and 64bit. - Functional changes for 64bit. - "tsc_disabled" is updated if "notsc" is passed at boottime. - Fallback to jiffies for sched_clock, incase notsc is passed on commandline. Signed-off-by: Alok N Kataria <akataria@vmware.com> Signed-off-by: Dan Hecht <dhecht@vmware.com> Cc: Dan Hecht <dhecht@vmware.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/tsc_64.c')
-rw-r--r--arch/x86/kernel/tsc_64.c67
1 files changed, 11 insertions, 56 deletions
diff --git a/arch/x86/kernel/tsc_64.c b/arch/x86/kernel/tsc_64.c
index 9898fb01edfd..69cbe4c9f050 100644
--- a/arch/x86/kernel/tsc_64.c
+++ b/arch/x86/kernel/tsc_64.c
@@ -13,12 +13,8 @@
13#include <asm/timer.h> 13#include <asm/timer.h>
14#include <asm/vgtod.h> 14#include <asm/vgtod.h>
15 15
16static int notsc __initdata = 0; 16extern int tsc_unstable;
17 17extern int tsc_disabled;
18unsigned int cpu_khz; /* TSC clocks / usec, not used here */
19EXPORT_SYMBOL(cpu_khz);
20unsigned int tsc_khz;
21EXPORT_SYMBOL(tsc_khz);
22 18
23/* Accelerators for sched_clock() 19/* Accelerators for sched_clock()
24 * convert from cycles(64bits) => nanoseconds (64bits) 20 * convert from cycles(64bits) => nanoseconds (64bits)
@@ -41,6 +37,7 @@ EXPORT_SYMBOL(tsc_khz);
41 * 37 *
42 * -johnstul@us.ibm.com "math is hard, lets go shopping!" 38 * -johnstul@us.ibm.com "math is hard, lets go shopping!"
43 */ 39 */
40
44DEFINE_PER_CPU(unsigned long, cyc2ns); 41DEFINE_PER_CPU(unsigned long, cyc2ns);
45 42
46static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu) 43static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
@@ -63,41 +60,6 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
63 local_irq_restore(flags); 60 local_irq_restore(flags);
64} 61}
65 62
66unsigned long long native_sched_clock(void)
67{
68 unsigned long a = 0;
69
70 /* Could do CPU core sync here. Opteron can execute rdtsc speculatively,
71 * which means it is not completely exact and may not be monotonous
72 * between CPUs. But the errors should be too small to matter for
73 * scheduling purposes.
74 */
75
76 rdtscll(a);
77 return cycles_2_ns(a);
78}
79
80/* We need to define a real function for sched_clock, to override the
81 weak default version */
82#ifdef CONFIG_PARAVIRT
83unsigned long long sched_clock(void)
84{
85 return paravirt_sched_clock();
86}
87#else
88unsigned long long
89sched_clock(void) __attribute__((alias("native_sched_clock")));
90#endif
91
92
93static int tsc_unstable;
94
95int check_tsc_unstable(void)
96{
97 return tsc_unstable;
98}
99EXPORT_SYMBOL_GPL(check_tsc_unstable);
100
101#ifdef CONFIG_CPU_FREQ 63#ifdef CONFIG_CPU_FREQ
102 64
103/* Frequency scaling support. Adjust the TSC based timer when the cpu frequency 65/* Frequency scaling support. Adjust the TSC based timer when the cpu frequency
@@ -281,14 +243,6 @@ __cpuinit int unsynchronized_tsc(void)
281 return num_present_cpus() > 1; 243 return num_present_cpus() > 1;
282} 244}
283 245
284int __init notsc_setup(char *s)
285{
286 notsc = 1;
287 return 1;
288}
289
290__setup("notsc", notsc_setup);
291
292static struct clocksource clocksource_tsc; 246static struct clocksource clocksource_tsc;
293 247
294/* 248/*
@@ -346,12 +300,13 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
346 300
347void __init init_tsc_clocksource(void) 301void __init init_tsc_clocksource(void)
348{ 302{
349 if (!notsc) { 303 if (tsc_disabled > 0)
350 clocksource_tsc.mult = clocksource_khz2mult(tsc_khz, 304 return;
351 clocksource_tsc.shift);
352 if (check_tsc_unstable())
353 clocksource_tsc.rating = 0;
354 305
355 clocksource_register(&clocksource_tsc); 306 clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
356 } 307 clocksource_tsc.shift);
308 if (check_tsc_unstable())
309 clocksource_tsc.rating = 0;
310
311 clocksource_register(&clocksource_tsc);
357} 312}