linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 8/11] Add a CPU KHZ calibration function to paravirt-ops
@ 2007-02-06  3:53 Zachary Amsden
  2007-02-06 12:26 ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Zachary Amsden @ 2007-02-06  3:53 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Andrew Morton, Andi Kleen,
	Rusty Russell, Jeremy Fitzhardinge, Chris Wright, Zachary Amsden

Provide a paravirtualized way to get the CPU clock frequency; this allows much
of the code in tsc.c to be shared between all paravirt implementations.

Subject: Add a CPU KHZ calibration function to paravirt-ops
Signed-off-by: Zachary Amsden <zach@vmware.com>

diff -r a08f195aa92a arch/i386/kernel/vmi.c
--- a/arch/i386/kernel/vmi.c	Fri Feb 02 16:30:59 2007 -0800
+++ b/arch/i386/kernel/vmi.c	Fri Feb 02 16:31:45 2007 -0800
@@ -881,6 +881,7 @@ static int __init activate_vmi(void)
 		paravirt_ops.setup_secondary_clock = vmi_timer_setup_secondary_alarm;
 #endif
 		paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles;
+ 		paravirt_ops.get_cpu_khz = vmi_cpu_khz;
 	}
 
 	/*
diff -r a08f195aa92a arch/i386/kernel/vmitime.c
--- a/arch/i386/kernel/vmitime.c	Fri Feb 02 16:30:59 2007 -0800
+++ b/arch/i386/kernel/vmitime.c	Fri Feb 02 16:30:59 2007 -0800
@@ -175,6 +175,15 @@ unsigned long long vmi_get_sched_cycles(
 	return read_available_cycles();
 }
 
+unsigned long vmi_cpu_khz(void)
+{
+	unsigned long long khz;
+
+	khz = vmi_timer_ops.get_cycle_frequency();
+	(void)do_div(khz, 1000);
+	return khz;
+}
+
 void __init vmi_time_init(void)
 {
 	unsigned long long cycles_per_sec, cycles_per_msec;
@@ -204,7 +213,6 @@ void __init vmi_time_init(void)
 	(void)do_div(cycles_per_alarm, alarm_hz);
 	cycles_per_msec = cycles_per_sec;
 	(void)do_div(cycles_per_msec, 1000);
-	cpu_khz = cycles_per_msec;
 
 	printk(KERN_WARNING "VMI timer cycles/sec = %llu ; cycles/jiffy = %llu ;"
 	       "cycles/alarm = %llu\n", cycles_per_sec, cycles_per_jiffy,
diff -r a08f195aa92a include/asm-i386/vmi_time.h
--- a/include/asm-i386/vmi_time.h	Fri Feb 02 16:30:59 2007 -0800
+++ b/include/asm-i386/vmi_time.h	Fri Feb 02 16:31:24 2007 -0800
@@ -50,6 +50,7 @@ extern unsigned long vmi_get_wallclock(v
 extern unsigned long vmi_get_wallclock(void);
 extern int vmi_set_wallclock(unsigned long now);
 extern unsigned long long vmi_get_sched_cycles(void);
+extern unsigned long vmi_cpu_khz(void);
 
 #ifdef CONFIG_X86_LOCAL_APIC
 extern void __init vmi_timer_setup_boot_alarm(void);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/11] Add a CPU KHZ calibration function to paravirt-ops
  2007-02-06  3:53 [PATCH 8/11] Add a CPU KHZ calibration function to paravirt-ops Zachary Amsden
@ 2007-02-06 12:26 ` Andi Kleen
  2007-02-06 21:54   ` Zachary Amsden
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2007-02-06 12:26 UTC (permalink / raw)
  To: Zachary Amsden
  Cc: Linux Kernel Mailing List, Andrew Morton, Rusty Russell,
	Jeremy Fitzhardinge, Chris Wright

On Mon, Feb 05, 2007 at 07:53:23PM -0800, Zachary Amsden wrote:
> Provide a paravirtualized way to get the CPU clock frequency; this allows much
> of the code in tsc.c to be shared between all paravirt implementations.

Is this really needed? 

What worries me somewhat of your patches is that you seem
to be quick at adding new hooks. But I would like to keep
paravirtops as minimal as possible with new hooks only
added when there is a very good justification.

I don't see it here.

-Andi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/11] Add a CPU KHZ calibration function to paravirt-ops
  2007-02-06 12:26 ` Andi Kleen
@ 2007-02-06 21:54   ` Zachary Amsden
  0 siblings, 0 replies; 3+ messages in thread
From: Zachary Amsden @ 2007-02-06 21:54 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Linux Kernel Mailing List, Andrew Morton, Rusty Russell,
	Jeremy Fitzhardinge, Chris Wright

Andi Kleen wrote:
> On Mon, Feb 05, 2007 at 07:53:23PM -0800, Zachary Amsden wrote:
>   
>> Provide a paravirtualized way to get the CPU clock frequency; this allows much
>> of the code in tsc.c to be shared between all paravirt implementations.
>>     
>
> Is this really needed? 
>   

Honestly, no.  But it is better and more accurate to do it.

> What worries me somewhat of your patches is that you seem
> to be quick at adding new hooks. But I would like to keep
> paravirtops as minimal as possible with new hooks only
> added when there is a very good justification.
>
> I don't see it here.
>   

We can calibrate CPU frequency pretty accurately, despite being in a VM 
where time does not operate in the normal way.  Many other hypervisors 
won't be able to do such a good job, or might not implement the required 
hardware.

Adding this hook allows everyone to just re-use all the frequency 
scaling / recalibration code in tsc.c.

The primary justification is allowing code re-use, which is why I 
allowed myself to add a hook.  I also want paravirt-ops to be as minimal 
as possible.

Zach

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-06 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-06  3:53 [PATCH 8/11] Add a CPU KHZ calibration function to paravirt-ops Zachary Amsden
2007-02-06 12:26 ` Andi Kleen
2007-02-06 21:54   ` Zachary Amsden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).