From: Keir Fraser <keir.xen@gmail.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: lock in vhpet
Date: Wed, 18 Apr 2012 08:13:27 +0100 [thread overview]
Message-ID: <CBB42827.30EE3%keir.xen@gmail.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E0D9CDC@SHSMSX101.ccr.corp.intel.com>
On 18/04/2012 01:52, "Zhang, Yang Z" <yang.z.zhang@intel.com> wrote:
>> It depends. Where an access is an apparently-atomic memory-mapped access,
>> but implemented as a sequence of operations in the hypervisor, the hypervisor
>> might need to maintain atomicity through locking.
>
> But if there already has lock inside guest for those access, and there have no
> other code patch(like timer callback function) in hypervisor to access the
> shared data, then we don't need to use lock in hypersivor.
If there is a memory-mapped register access which is atomic on bare metal,
the guest may not bother with locking. We have to maintain that apparent
atomicity ourselves by implementing serialisation in the hypervisor.
>>> I don't know whether all those locks are necessary, but at least the
>>> lock for vhpet, especially the reading lock, is not required.
>>
>> This is definitely not true, for example locking is required around calls to
>> create_periodic_time(), to serialise them. So in general the locking I added,
>> even in vhpet.c is required. If you have a specific hot path you are looking
>> to
>> optimise, and especially if you have numbers to back that up, then we can
>> consider specific localised optimisations to avoid locking where we can
>> reason
>> it is not needed.
> As I mentioned, if the guest can ensure there only one CPU to access the hpet
> at same time, this means the access itself already is serialized.
> Yes.Win8 is booting very slowly w/ more than 16 VCPUs. And this is due to the
> big lock in reading hpet. Also, the xentrace data shows lots of vmexit which
> mainly from PAUSE instruction from other cpus. So I think if guest already
> uses lock to protect the hpet access, why hypervisor do the same thing too?
If the HPET accesses are atomic on bare metal, we have to maintain that,
even if some guests have extra locking themselves. Also, in some cases Xen
needs locking to correctly maintain its own internal state regardless of
what an (untrusted) guest might do. So we cannot just get rid of the vhpet
lock everywhere. It's definitely not correct to do so. Optimising the hpet
read path however, sounds okay. I agree the lock may not be needed on that
specific path.
-- Keir
next prev parent reply other threads:[~2012-04-18 7:13 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-17 3:26 lock in vhpet Zhang, Yang Z
2012-04-17 7:27 ` Keir Fraser
2012-04-18 0:52 ` Zhang, Yang Z
2012-04-18 7:13 ` Keir Fraser [this message]
2012-04-18 7:55 ` Zhang, Yang Z
2012-04-18 8:29 ` Keir Fraser
2012-04-18 9:14 ` Keir Fraser
2012-04-18 9:30 ` Keir Fraser
2012-04-19 5:19 ` Zhang, Yang Z
2012-04-19 8:27 ` Tim Deegan
2012-04-19 8:47 ` Keir Fraser
2012-04-23 7:36 ` Zhang, Yang Z
2012-04-23 7:43 ` Jan Beulich
2012-04-23 8:15 ` Zhang, Yang Z
2012-04-23 8:22 ` Keir Fraser
2012-04-23 9:14 ` Tim Deegan
2012-04-23 15:26 ` Andres Lagar-Cavilla
2012-04-24 9:15 ` Tim Deegan
2012-04-24 13:28 ` Andres Lagar-Cavilla
2012-04-23 17:18 ` Andres Lagar-Cavilla
2012-04-24 8:58 ` Zhang, Yang Z
2012-04-24 9:16 ` Tim Deegan
2012-04-25 0:27 ` Zhang, Yang Z
2012-04-25 1:40 ` Andres Lagar-Cavilla
2012-04-25 1:48 ` Zhang, Yang Z
2012-04-25 2:31 ` Andres Lagar-Cavilla
2012-04-25 2:36 ` Zhang, Yang Z
2012-04-25 2:42 ` Andres Lagar-Cavilla
2012-04-25 3:12 ` Zhang, Yang Z
2012-04-25 3:34 ` Andres Lagar-Cavilla
2012-04-25 5:18 ` Zhang, Yang Z
2012-04-25 8:07 ` Jan Beulich
2012-04-26 21:25 ` Tim Deegan
2012-04-27 0:46 ` Zhang, Yang Z
2012-04-27 0:51 ` Andres Lagar-Cavilla
2012-04-27 1:24 ` Zhang, Yang Z
2012-04-27 8:36 ` Zhang, Yang Z
2012-04-27 3:02 ` Andres Lagar-Cavilla
2012-04-27 9:26 ` Tim Deegan
2012-04-27 14:17 ` Andres Lagar-Cavilla
2012-04-27 21:08 ` Andres Lagar-Cavilla
2012-05-16 11:36 ` Zhang, Yang Z
2012-05-16 12:36 ` Tim Deegan
2012-05-17 10:57 ` Tim Deegan
2012-05-28 6:54 ` Zhang, Yang Z
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=CBB42827.30EE3%keir.xen@gmail.com \
--to=keir.xen@gmail.com \
--cc=xen-devel@lists.xensource.com \
--cc=yang.z.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;
as well as URLs for NNTP newsgroup(s).