From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
"Xen-Devel (E-mail)" <xen-devel@lists.xensource.com>,
Keir Fraser <keir.fraser@eu.citrix.com>,
Jan Beulich <JBeulich@novell.com>
Subject: Re: RE: rdtsc: correctness vs performance on Xen (and KVM?)
Date: Tue, 01 Sep 2009 15:21:36 -0700 [thread overview]
Message-ID: <4A9D9E70.8000905@goop.org> (raw)
In-Reply-To: <b5efa656-50f2-452d-89b3-2632afabadfc@default>
On 09/01/09 15:08, Dan Magenheimer wrote:
>>> Just like what is being used to allow apps to get the CPU
>>>
>> number on native
>>
>>> kernels (or the vCPU one on Xen-ified ones): Have a GDT
>>>
>> entry the limit of
>>
>>> which is the number you want, and have the app use the lsl
>>>
>> instruction to
>>
>>> get at it.
>>>
>> Yes, that's true. Xen could provide such a segment descriptor
>> in its private
>> area of the GDT. The issue then would be that, in a compound pvclock
>> operation spanning multiple machine instructions, the pCPU
>> number revealed
>> by the LSL instruction can be stale by the time it is used
>> later in the
>> compound operation.
>>
> The algorithm could check the pCPU number before and after
> reading the pvclock data and doing the rdtsc, and if they
> don't match, start again. (Doesn't the pvclock algorithm
> already do that with some versioning number in the pvclock
> data itself to ensure that the rest of the data didn't
> change while it was being read?)
>
There's still a race there, if the thread switched PCPU twice during the
operation:
<running on PCPU A>
get CPU #
<switch to PCPU B>
read tsc
apply corrections from (from PCPU A)
<switch to PCPU A>
check CPU # is the same as we started with: all OK!
note that the <switch to PCPU B> could either be a result of the Xen
scheduler moving the VCPU *or* the Linux scheduler moving the thread to
a different VCPU. In the former case, Xen could update a version
counter to help detect the discontinuity, but it doesn't really know
about guest scheduling decisions. I guess the guest kernel could update
the pvclock version counter itself.
> I'm clueless about GDTs and the LSL instrution so would
> need some help prototyping this.
>
It's what vsyscall already uses. Your scheme is precisely analogous to
what's already there.
J
next prev parent reply other threads:[~2009-09-01 22:21 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-25 21:54 write_tsc in a PV domain? Dan Magenheimer
2009-08-25 22:28 ` Jeremy Fitzhardinge
2009-08-25 23:09 ` Dan Magenheimer
2009-08-26 6:23 ` Keir Fraser
2009-08-26 15:42 ` Dan Magenheimer
2009-08-26 15:58 ` Keir Fraser
2009-08-26 19:45 ` Jeremy Fitzhardinge
2009-08-26 20:23 ` Dan Magenheimer
2009-08-26 22:30 ` Jeremy Fitzhardinge
2009-08-26 23:10 ` Dan Magenheimer
2009-08-27 8:39 ` Chris Lalancette
2009-08-27 13:00 ` Dan Magenheimer
2009-08-27 13:17 ` Chris Lalancette
2009-08-27 8:48 ` Alan Cox
2009-08-27 19:10 ` Jeremy Fitzhardinge
2009-08-28 3:29 ` Dan Magenheimer
2009-08-28 9:49 ` Alan Cox
2009-08-28 15:16 ` Dan Magenheimer
2009-08-28 15:30 ` Alan Cox
2009-08-28 17:49 ` rdtsc: correctness vs performance on Xen (and KVM?) Dan Magenheimer
2009-08-31 23:52 ` Dan Magenheimer
2009-09-01 0:22 ` Jeremy Fitzhardinge
2009-09-01 13:54 ` Dan Magenheimer
2009-09-01 14:34 ` Keir Fraser
2009-09-01 14:53 ` Dan Magenheimer
2009-09-01 15:08 ` Keir Fraser
2009-09-01 15:26 ` Dan Magenheimer
2009-09-01 15:32 ` Jan Beulich
2009-09-01 15:56 ` Dan Magenheimer
2009-09-01 16:04 ` Jan Beulich
2009-09-01 16:41 ` Dan Magenheimer
2009-09-02 7:05 ` Jan Beulich
2009-09-01 21:25 ` Keir Fraser
2009-09-01 22:08 ` Dan Magenheimer
2009-09-01 22:21 ` Jeremy Fitzhardinge [this message]
2009-09-01 22:41 ` Dan Magenheimer
2009-09-01 23:26 ` Jeremy Fitzhardinge
2009-09-02 7:20 ` Keir Fraser
2009-09-02 21:44 ` Jeremy Fitzhardinge
2009-09-02 21:50 ` Keir Fraser
2009-09-02 22:05 ` Jeremy Fitzhardinge
2009-09-03 8:23 ` Jan Beulich
2009-09-03 17:29 ` Jeremy Fitzhardinge
2009-09-04 7:19 ` Jan Beulich
2009-09-04 15:44 ` Jeremy Fitzhardinge
2009-09-03 14:22 ` Dan Magenheimer
2009-09-02 7:16 ` Jan Beulich
2009-09-02 7:01 ` Jan Beulich
2009-09-01 16:06 ` Keir Fraser
2009-09-01 16:55 ` Dan Magenheimer
2009-09-01 15:43 ` Keir Fraser
2009-08-28 17:49 ` write_tsc in a PV domain? Dan Magenheimer
2009-08-28 17:02 ` Jeremy Fitzhardinge
2009-08-28 17:49 ` Dan Magenheimer
2009-08-28 23:01 ` Jeremy Fitzhardinge
2009-08-29 17:51 ` Dan Magenheimer
2009-08-31 18:11 ` Dan Magenheimer
2009-08-31 19:06 ` Keir Fraser
2009-08-31 21:06 ` Dan Magenheimer
2009-09-01 7:16 ` Keir Fraser
2009-08-31 19:18 ` Jeremy Fitzhardinge
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=4A9D9E70.8000905@goop.org \
--to=jeremy@goop.org \
--cc=JBeulich@novell.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dan.magenheimer@oracle.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.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 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.