From: Roman Kagan <rkagan@virtuozzo.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: <kvm@vger.kernel.org>, "Denis V. Lunev" <den@openvz.org>,
Owen Hofmann <osh@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] x86/kvm: fix condition to update kvm master clocks
Date: Thu, 9 Jun 2016 22:19:25 +0300 [thread overview]
Message-ID: <20160609191923.GA3258@rkaganip.lan> (raw)
In-Reply-To: <20160609182501.GA24024@amt.cnet>
On Thu, Jun 09, 2016 at 03:25:02PM -0300, Marcelo Tosatti wrote:
> On Thu, Jun 09, 2016 at 03:09:46PM +0300, Roman Kagan wrote:
> > In general I'm starting to feel the shared memory clock is trying to
> > provide stronger guarantees than really useful. E.g. there's no such
> > thing as synchronous TSC between vCPUs in a virtual machine, so every
> > guest assuming it is broken;
>
> There is, the TSC is monotonic between pCPUs:
>
> pCPU1 | pCPU2
>
> 1. a = read tsc
> 2. b = read tsc.
Right, the processor guarantees that upon rdtsc completion the contents
of %rdx, %rax is ordered properly across CPUs. However, what matters is
the comparison of the values between CPUs which happens in the code that
follows rdtsc, and which is subject to delays due to vCPUs being
scheduled out. E.g.
vCPU1 | vCPU2
|
1. a = rdtsc |
2. preemption by host | b = rdtsc
3. enter to guest | return t(b)
4. return t(a) |
t(a) < t(b)
In particular, in guest linux case, in the above scenario vCPU2 would
update the timekeeper and store tsc_timestamp onto it; then vCPU1 would
use the older tsc value to calculate the time and get negative tsc
delta.
> > in reality that means that every sane guest
> > must tolerate certain violations of monotonicity when multiple CPUs are
> > used for timekeeping. I wonder if this consideration can allow for some
> > simplification of the paravirtual clock code...
>
> I think applications can fail.
The guest kernel must take care of compensating those violations, so
that applications see consistent view of time.
[ I'll need some time to grok the rest of your message, as I'm still new
to the timekeeping code, so I'll reply to it in another mail. ]
Thanks,
Roman.
next prev parent reply other threads:[~2016-06-09 19:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 14:49 [PATCH] x86/kvm: fix condition to update kvm master clocks Roman Kagan
2016-05-26 20:19 ` Radim Krčmář
2016-05-27 17:28 ` Roman Kagan
2016-05-27 18:11 ` Radim Krčmář
2016-05-27 18:46 ` Roman Kagan
2016-05-27 19:29 ` Radim Krčmář
2016-05-29 23:38 ` Marcelo Tosatti
2016-06-09 3:27 ` Marcelo Tosatti
2016-06-09 3:45 ` Marcelo Tosatti
2016-06-09 12:09 ` Roman Kagan
2016-06-09 18:25 ` Marcelo Tosatti
2016-06-09 19:19 ` Roman Kagan [this message]
2016-06-13 17:07 ` Roman Kagan
2016-06-14 22:11 ` Marcelo Tosatti
2016-06-13 17:19 ` Roman Kagan
2016-06-17 22:21 ` Marcelo Tosatti
2016-06-20 17:22 ` Roman Kagan
2016-06-20 21:29 ` Marcelo Tosatti
2016-06-21 14:40 ` Roman Kagan
2016-06-21 21:28 ` 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=20160609191923.GA3258@rkaganip.lan \
--to=rkagan@virtuozzo.com \
--cc=den@openvz.org \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=osh@google.com \
--cc=pbonzini@redhat.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