All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yang, Sheng" <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [RFC][PATCH 1/2] KVM: In-kernel PIT model
Date: Wed, 23 Jan 2008 14:00:35 +0800	[thread overview]
Message-ID: <200801231400.36063.sheng.yang@intel.com> (raw)
In-Reply-To: <4795F582.7050802-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

On Tuesday 22 January 2008 21:54:10 Avi Kivity wrote:
> Yang, Sheng wrote:
> > +
> > +/* Compute with 96 bit intermediate result: (a*b)/c */
> > +static u64 muldiv64(u64 a, u32 b, u32 c)
>
> Why do we need such high accuracy for the pit?

The direct reason is we using TSC as the reference of pit count_load_time. I 
think the only alternative is using host ACPI PM timer. But it will wrapped 
soon...

>
> > +
> > +static int pit_get_out(struct kvm *kvm, int channel)
> > +{
> > +	struct PITChannelState *c =
> > +		&kvm->arch.vpit->pit_state.channels[channel];
> > +	struct kvm_vcpu *vcpu = kvm->vcpus[0];
> > +	u64 d, t;
> > +	int out;
> > +
> > +	ASSERT(mutex_is_locked(&kvm->arch.vpit->pit_state.lock));
> > +
> > +	kvm_get_msr(vcpu, MSR_IA32_TIME_STAMP_COUNTER, &t);
> > +	d = muldiv64(t - c->count_load_time, PIT_FREQ, cpu_khz * 1000);
>
> I assume this is to correlate the tsc and the pit counters.  Doesn't
> this break with cpu frequency scaling or with vcpu migrations?

I think the cpu frequency scaling will affect TSC, though cpu_khz would be 
changed along with it. 

>
> What if this is called within the context of vcpu 1?  Not sure
> kvm_get_msr() will work correctly at all.

I don't think so. kvm_get_msr() with TSC only read guest tsc, which is 
indentity for the domain, not specific for vcpu. And I indicated vcpu0 as 
vcpu(though won't be refered). But I may do it more clear in the future.

>
> > +struct PITTimer {
> >
> > +
> > +struct PITChannelState {
> > +
> > +struct PITState {
>
> Please use the traditional naming convention (pit_timer,
> pit_channel_state, pit_state)

Sure.

-- 
Thanks
Yang, Sheng

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2008-01-23  6:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-21  9:18 [RFC][PATCH 1/2] KVM: In-kernel PIT model Yang, Sheng
     [not found] ` <200801211718.23664.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-01-21  9:53   ` Jan Kiszka
     [not found]     ` <47946B96.4040508-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-21 10:14       ` Avi Kivity
     [not found]         ` <47947088.5030309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-21 10:22           ` Jan Kiszka
     [not found]             ` <47947252.7000606-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-21 10:44               ` Avi Kivity
2008-01-21 10:28       ` Carsten Otte
     [not found]         ` <479473D0.7000002-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-22  1:15           ` Yang, Sheng
2008-01-22 13:54   ` Avi Kivity
     [not found]     ` <4795F582.7050802-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-23  6:00       ` Yang, Sheng [this message]
     [not found]         ` <200801231400.36063.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-01-23  9:46           ` Avi Kivity
     [not found]             ` <47970CEE.2050000-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-24  9:29               ` Yang, Sheng
     [not found]                 ` <200801241729.18787.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-01-24  9:26                   ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200801231400.36063.sheng.yang@intel.com \
    --to=sheng.yang-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.