public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: "Auld, Will" <will.auld@intel.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Zhang, Xiantao" <xiantao.zhang@intel.com>
Subject: Re: [PATCH] Enabling IA32_TSC_ADJUST for guest VM
Date: Tue, 09 Oct 2012 16:30:28 +0200	[thread overview]
Message-ID: <50743504.8010207@redhat.com> (raw)
In-Reply-To: <20121009142752.GB10848@amt.cnet>

On 10/09/2012 04:27 PM, Marcelo Tosatti wrote:
> On Tue, Oct 09, 2012 at 04:26:32PM +0200, Avi Kivity wrote:
>> On 10/09/2012 04:24 PM, Marcelo Tosatti wrote:
>> > On Tue, Oct 09, 2012 at 02:12:18PM +0200, Avi Kivity wrote:
>> >> On 10/08/2012 07:30 PM, Marcelo Tosatti wrote:
>> >> > 
>> >> > From Intel's manual:
>> >> > 
>> >> > • If an execution of WRMSR to the IA32_TIME_STAMP_COUNTER MSR adds (or
>> >> > subtracts) value X from the TSC,
>> >> > the logical processor also adds (or subtracts) value X from the
>> >> > IA32_TSC_ADJUST MSR.
>> >> > 
>> >> > This is not handled in the patch. 
>> >> > 
>> >> > To support migration, it will be necessary to differentiate between
>> >> > guest initiated and userspace-model initiated msr write. That is, 
>> >> > only guest initiated TSC writes should affect the value of 
>> >> > IA32_TSC_ADJUST MSR.
>> >> > 
>> >> > Avi, any better idea?
>> >> > 
>> >> 
>> >> I think we need that anyway, since there are some read-only MSRs that
>> >> need to be configured by the host (nvmx capabilities).  So if we add
>> >> that feature it will be useful elsewhere.  I don't think it's possible
>> >> to do it in any other way:
>> >> 
>> >> "Local offset value of the IA32_TSC for a
>> >> logical processor. Reset value is Zero. A
>> >> write to IA32_TSC will modify the local
>> >> offset in IA32_TSC_ADJUST and the
>> >> content of IA32_TSC, but does not affect
>> >> the internal invariant TSC hardware."
>> >> 
>> >> What we want to do is affect the internal invariant TSC hardware, so we
>> >> can't do that through the normal means.
>> >> 
>> >> btw, will tsc writes from userspace (after live migration) cause tsc
>> >> skew?  If so we should think how to model a guest-wide tsc.
>> > 
>> > No because there is an easy shortcut:
>> > 
>> >     if (level == KVM_PUT_FULL_STATE) {
>> >         /*
>> >          * KVM is yet unable to synchronize TSC values of multiple VCPUs
>> >          * on
>> >          * writeback. Until this is fixed, we only write the offset to
>> >          * SMP
>> >          * guests after migration, desynchronizing the VCPUs, but
>> >          * avoiding
>> >          * huge jump-backs that would occur without any writeback at
>> >          * all.
>> >          */
>> >         if (smp_cpus == 1 || env->tsc != 0) {
>> >             kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSC, env->tsc);
>> >         }
>> >     }
>> 
>> Still we write back after migration.  So this needs to be fixed (or I
>> misunderstood you).
> 
> Handled by kvm_write_tsc() in x86.c. Is this what you mean?
> 

It will generate a call to ->write_tsc_offset().  Will the values be the
same for all vcpus?  Note the inputs won't be the same.


-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-10-09 14:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 17:44 [PATCH] Enabling IA32_TSC_ADJUST for guest VM Auld, Will
2012-09-20 11:13 ` Avi Kivity
2012-09-20 11:15 ` Avi Kivity
2012-09-26 21:34 ` Marcelo Tosatti
2012-09-26 22:58   ` Auld, Will
2012-09-27  0:29     ` Marcelo Tosatti
2012-09-27  0:30       ` Marcelo Tosatti
2012-09-27  0:50       ` Auld, Will
2012-09-27 11:31         ` Marcelo Tosatti
2012-09-27 11:48           ` Marcelo Tosatti
2012-09-28  2:07             ` Auld, Will
2012-09-28 13:24               ` Marcelo Tosatti
2012-10-08 17:30 ` Marcelo Tosatti
2012-10-09 12:12   ` Avi Kivity
2012-10-09 14:24     ` Marcelo Tosatti
2012-10-09 14:26       ` Avi Kivity
2012-10-09 14:27         ` Marcelo Tosatti
2012-10-09 14:30           ` Avi Kivity [this message]
2012-10-09 15:52             ` Marcelo Tosatti
2012-10-09 16:10     ` Auld, Will
2012-10-10 12:52       ` Marcelo Tosatti
2012-10-11  0:47         ` Auld, Will
2012-10-11  8:56           ` Marcelo Tosatti

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=50743504.8010207@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=will.auld@intel.com \
    --cc=xiantao.zhang@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox