diff options
author | Zachary Amsden <zach@vmware.com> | 2007-03-05 03:30:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-03-05 10:57:52 -0500 |
commit | 1182d8528b620c23d043bccbbef092b42062960a (patch) | |
tree | 3df690a1a731811f8fecda06cb785a5a7b06d4d0 /arch | |
parent | 6cb9a8350aee789100a365794272ed20cc8f2401 (diff) |
[PATCH] vmi: cpu cycles fix
In order to share the common code in tsc.c which does CPU Khz calibration, we
need to make an accurate value of CPU speed available to the tsc.c code. This
value loses a lot of precision in a VM because of the timing differences with
real hardware, but we need it to be as precise as possible so the guest can
make accurate time calculations with the cycle counters.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/kernel/paravirt.c | 1 | ||||
-rw-r--r-- | arch/i386/kernel/tsc.c | 2 | ||||
-rw-r--r-- | arch/i386/kernel/vmi.c | 1 | ||||
-rw-r--r-- | arch/i386/kernel/vmitime.c | 10 |
4 files changed, 12 insertions, 2 deletions
diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c index 31bbe70d1e02..8352394d5efb 100644 --- a/arch/i386/kernel/paravirt.c +++ b/arch/i386/kernel/paravirt.c | |||
@@ -522,6 +522,7 @@ struct paravirt_ops paravirt_ops = { | |||
522 | .read_tsc = native_read_tsc, | 522 | .read_tsc = native_read_tsc, |
523 | .read_pmc = native_read_pmc, | 523 | .read_pmc = native_read_pmc, |
524 | .get_scheduled_cycles = native_read_tsc, | 524 | .get_scheduled_cycles = native_read_tsc, |
525 | .get_cpu_khz = native_calculate_cpu_khz, | ||
525 | .load_tr_desc = native_load_tr_desc, | 526 | .load_tr_desc = native_load_tr_desc, |
526 | .set_ldt = native_set_ldt, | 527 | .set_ldt = native_set_ldt, |
527 | .load_gdt = native_load_gdt, | 528 | .load_gdt = native_load_gdt, |
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c index c9c9d54c91f6..59222a04234b 100644 --- a/arch/i386/kernel/tsc.c +++ b/arch/i386/kernel/tsc.c | |||
@@ -117,7 +117,7 @@ unsigned long long sched_clock(void) | |||
117 | return cycles_2_ns(this_offset); | 117 | return cycles_2_ns(this_offset); |
118 | } | 118 | } |
119 | 119 | ||
120 | static unsigned long calculate_cpu_khz(void) | 120 | unsigned long native_calculate_cpu_khz(void) |
121 | { | 121 | { |
122 | unsigned long long start, end; | 122 | unsigned long long start, end; |
123 | unsigned long count; | 123 | unsigned long count; |
diff --git a/arch/i386/kernel/vmi.c b/arch/i386/kernel/vmi.c index 556b9a6b7365..acdfe69fb7ad 100644 --- a/arch/i386/kernel/vmi.c +++ b/arch/i386/kernel/vmi.c | |||
@@ -874,6 +874,7 @@ static inline int __init activate_vmi(void) | |||
874 | paravirt_ops.setup_secondary_clock = vmi_timer_setup_secondary_alarm; | 874 | paravirt_ops.setup_secondary_clock = vmi_timer_setup_secondary_alarm; |
875 | #endif | 875 | #endif |
876 | paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles; | 876 | paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles; |
877 | paravirt_ops.get_cpu_khz = vmi_cpu_khz; | ||
877 | } | 878 | } |
878 | if (!disable_noidle) | 879 | if (!disable_noidle) |
879 | para_fill(safe_halt, Halt); | 880 | para_fill(safe_halt, Halt); |
diff --git a/arch/i386/kernel/vmitime.c b/arch/i386/kernel/vmitime.c index f2aa8fab8c02..4bb218e2eb14 100644 --- a/arch/i386/kernel/vmitime.c +++ b/arch/i386/kernel/vmitime.c | |||
@@ -177,6 +177,15 @@ unsigned long long vmi_get_sched_cycles(void) | |||
177 | return read_available_cycles(); | 177 | return read_available_cycles(); |
178 | } | 178 | } |
179 | 179 | ||
180 | unsigned long vmi_cpu_khz(void) | ||
181 | { | ||
182 | unsigned long long khz; | ||
183 | |||
184 | khz = vmi_timer_ops.get_cycle_frequency(); | ||
185 | (void)do_div(khz, 1000); | ||
186 | return khz; | ||
187 | } | ||
188 | |||
180 | void __init vmi_time_init(void) | 189 | void __init vmi_time_init(void) |
181 | { | 190 | { |
182 | unsigned long long cycles_per_sec, cycles_per_msec; | 191 | unsigned long long cycles_per_sec, cycles_per_msec; |
@@ -206,7 +215,6 @@ void __init vmi_time_init(void) | |||
206 | (void)do_div(cycles_per_alarm, alarm_hz); | 215 | (void)do_div(cycles_per_alarm, alarm_hz); |
207 | cycles_per_msec = cycles_per_sec; | 216 | cycles_per_msec = cycles_per_sec; |
208 | (void)do_div(cycles_per_msec, 1000); | 217 | (void)do_div(cycles_per_msec, 1000); |
209 | cpu_khz = cycles_per_msec; | ||
210 | 218 | ||
211 | printk(KERN_WARNING "VMI timer cycles/sec = %llu ; cycles/jiffy = %llu ;" | 219 | printk(KERN_WARNING "VMI timer cycles/sec = %llu ; cycles/jiffy = %llu ;" |
212 | "cycles/alarm = %llu\n", cycles_per_sec, cycles_per_jiffy, | 220 | "cycles/alarm = %llu\n", cycles_per_sec, cycles_per_jiffy, |