From: Joerg Roedel <joerg.roedel@amd.com>
To: Ryan Harper <ryanh@us.ibm.com>
Cc: kvm-devel@lists.sourceforge.net
Subject: Re: [RFC][PATCH] svm.c: tsc unsigned delta calculation
Date: Tue, 13 May 2008 12:11:29 +0200 [thread overview]
Message-ID: <20080513101129.GA6136@amd.com> (raw)
In-Reply-To: <20080507220102.GQ17938@us.ibm.com>
On Wed, May 07, 2008 at 05:01:02PM -0500, Ryan Harper wrote:
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 5528121..c919ddd 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -685,8 +685,14 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> * increasing TSC.
> */
> rdtscll(tsc_this);
> - delta = vcpu->arch.host_tsc - tsc_this;
> - svm->vmcb->control.tsc_offset += delta;
> + /* we only need to adjust this if the old tsc was ahead
> + * also, we'll generate a massively large u64 value if
> + * tsc_this is less than host_tsc because of unsigned math
> + */
> + if (tsc_this < vcpu->arch.host_tsc) {
> + delta = vcpu->arch.host_tsc - tsc_this;
> + svm->vmcb->control.tsc_offset += delta;
> + }
> vcpu->cpu = cpu;
> kvm_migrate_apic_timer(vcpu);
> }
Hmm, I think this can result in inaccurate guest time because it makes
the tsc hopping. Does it fix the problem when you make delta an s64?
Joerg
--
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
-------------------------------------------------------------------------
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/
prev parent reply other threads:[~2008-05-13 10:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 22:01 [RFC][PATCH] svm.c: tsc unsigned delta calculation Ryan Harper
2008-05-07 22:29 ` Anthony Liguori
2008-05-13 10:11 ` Joerg Roedel [this message]
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=20080513101129.GA6136@amd.com \
--to=joerg.roedel@amd.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=ryanh@us.ibm.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