From: "Fernando Luis Vázquez Cao" <fernando_b1@lab.ntt.co.jp>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Will Auld <will.auld@intel.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] target-i386: clear guest TSC on reset
Date: Mon, 09 Dec 2013 17:50:17 +0900 [thread overview]
Message-ID: <52A58449.6020707@lab.ntt.co.jp> (raw)
In-Reply-To: <20131206142252.GA7081@amt.cnet>
On 12/06/2013 11:22 PM, Marcelo Tosatti wrote:
> On Fri, Dec 06, 2013 at 05:24:18PM +0900, Fernando Luis Vázquez Cao wrote:
>> I also wanted to make sure that the initialization that we do
>> in kvm_arch_vcpu_postcreate on power up and the subsequent
>> TSC writeback work well together, but I didn't have time to
>> test it (reading the code, I would say that the TSC generation
>> counter may end up being increased a few times but the TSCs
>> would eventually converge).
> A basic test should be fine, because the matching code is in use
> today.
I applied my two patches to QEMU and I did some testing
with SMP guests (4 VCPUs).
When the host's TSC is stable all the TSC offsets are matched
as expected:
[ 4544.779699] kvm: VCPU 0 new tsc generation 1, clock 0
[ 4544.799691] kvm: VCPU 1 matched tsc offset for 0
[ 4544.835687] kvm: VCPU 2 matched tsc offset for 0
[ 4544.882229] kvm: VCPU 3 matched tsc offset for 0
[ 4544.983740] kvm: VCPU 0 matched tsc offset for 0
[ 4545.015727] kvm: VCPU 1 matched tsc offset for 0
[ 4545.031762] kvm: VCPU 2 matched tsc offset for 0
[ 4545.043756] kvm: VCPU 3 matched tsc offset for 0
[ 4545.382113] kvm: VCPU 0 matched tsc offset for 0
[ 4545.382138] kvm: VCPU 1 matched tsc offset for 0
[ 4545.382155] kvm: VCPU 2 matched tsc offset for 0
[ 4545.382171] kvm: VCPU 3 matched tsc offset for 0
Regarding unstable TSC hosts, I created one by executing
TSCBSP=`rdmsr -d -p 0 16`; sleep 1s; wrmsr -p 0 16 $TSCBSP
as you suggested. After doing this KVM will adjust the TSC
offsets to make up for the deltas on the host side:
[ 5232.172074] kvm: VCPU 0 new tsc generation 1, clock 0
[ 5232.180759] kvm: SMP vm created on host with unstable TSC; guest
TSC will not be reliable
[ 5232.204069] kvm: VCPU 1 adjusted tsc offset by 105344
[ 5232.268070] kvm: VCPU 2 adjusted tsc offset by 210721
[ 5232.332066] kvm: VCPU 3 adjusted tsc offset by 210708
[ 5232.444127] kvm: VCPU 0 adjusted tsc offset by 368959
[ 5232.458448] kvm: VCPU 1 adjusted tsc offset by 47158
[ 5232.470400] kvm: VCPU 2 adjusted tsc offset by 39352
[ 5232.482359] kvm: VCPU 3 adjusted tsc offset by 39371
[ 5232.875343] kvm: VCPU 0 adjusted tsc offset by 1293878
[ 5232.875371] kvm: VCPU 1 adjusted tsc offset by 121
[ 5232.875392] kvm: VCPU 2 adjusted tsc offset by 69
[ 5232.875412] kvm: VCPU 3 adjusted tsc offset by 62
But despite KVM's efforts on the guest side the check in
check_tsc_sync_source() fails and the TSC is marked unstable:
tsc: Marking TSC unstable due to check_tsc_sync_source failed
By the way, without my patches applied to QEMU the end result
is the same:
[ 266.300068] kvm: VCPU 0 new tsc generation 1, clock 0
[ 266.308746] kvm: SMP vm created on host with unstable TSC; guest
TSC will not be reliable
[ 266.332067] kvm: VCPU 1 adjusted tsc offset by 105354
[ 266.396065] kvm: VCPU 2 adjusted tsc offset by 210714
[ 266.428273] kvm: VCPU 3 adjusted tsc offset by 106045
In other words, things seem to be working as expected.
- Fernando
next prev parent reply other threads:[~2013-12-09 8:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1386054500.25757.10.camel@nexus>
[not found] ` <529D90A6.2080801@lab.ntt.co.jp>
2013-12-05 6:08 ` [Qemu-devel] [PATCH] kvm: clear guest TSC on reset Fernando Luis Vázquez Cao
2013-12-05 6:15 ` [Qemu-devel] [PATCH] target-i386: " Fernando Luis Vázquez Cao
2013-12-05 9:28 ` Paolo Bonzini
2013-12-05 13:15 ` Fernando Luis Vazquez Cao
2013-12-05 13:53 ` Paolo Bonzini
2013-12-05 15:42 ` Fernando Luis Vazquez Cao
2013-12-05 16:02 ` Paolo Bonzini
2013-12-05 16:40 ` Marcelo Tosatti
2013-12-05 17:06 ` Marcelo Tosatti
2013-12-05 16:17 ` Marcelo Tosatti
2013-12-05 16:38 ` Paolo Bonzini
2013-12-06 8:24 ` Fernando Luis Vázquez Cao
2013-12-06 8:33 ` [Qemu-devel] [PATCH 1//2 v3] " Fernando Luis Vázquez Cao
2013-12-06 8:38 ` [Qemu-devel] [PATCH 2/2] target-i386: do not special case TSC writeback Fernando Luis Vázquez Cao
2013-12-06 8:36 ` [Qemu-devel] [PATCH] target-i386: clear guest TSC on reset Paolo Bonzini
2013-12-06 8:56 ` Fernando Luis Vázquez Cao
2013-12-06 9:08 ` Paolo Bonzini
2013-12-06 9:20 ` Fernando Luis Vazquez Cao
2013-12-06 14:22 ` Marcelo Tosatti
2013-12-09 8:50 ` Fernando Luis Vázquez Cao [this message]
2013-12-12 2:52 ` Fernando Luis Vázquez Cao
2013-12-12 12:18 ` Paolo Bonzini
2013-12-05 16:12 ` Marcelo Tosatti
2013-12-05 16:32 ` Paolo Bonzini
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=52A58449.6020707@lab.ntt.co.jp \
--to=fernando_b1@lab.ntt.co.jp \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=will.auld@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;
as well as URLs for NNTP newsgroup(s).