From: Tamas K Lengyel <tamas.lengyel@zentific.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Kevin Tian <kevin.tian@intel.com>, Tim Deegan <tim@xen.org>,
Jun Nakajima <jun.nakajima@intel.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: Question about VPID during MOV-TO-CR3
Date: Fri, 7 Oct 2016 09:41:46 -0600 [thread overview]
Message-ID: <CAErYnshA8JceF+7dUiFSRqYHTfBVFhgojEuyut5tMevKQ+W-TQ@mail.gmail.com> (raw)
In-Reply-To: <57F7DC120200007800115B6E@prv-mh.provo.novell.com>
On Fri, Oct 7, 2016 at 9:32 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>> On 04.10.16 at 17:06, <tim@xen.org> wrote:
>> At 08:29 -0600 on 04 Oct (1475569774), Jan Beulich wrote:
>>> >>> On 04.10.16 at 16:12, <tamas.lengyel@zentific.com> wrote:
>>> > yes, I understand that is the case when you do need to flush a guest.
>>> > And yes, there seem to be paths that require to bump the tag of a
>>> > specific guest for certain events (mov-to-cr4 with paging mode changes
>>> > for example). What I'm poking at it here is that we invalidate the
>>> > guest TLBs for _all_ guests very frequently. I can't find an
>>> > explanation for why _that_ is required. AFAIK having the TLB tag
>>> > guarantees that no other guest or Xen will have a chance to bump into
>>> > stale entries given no guests or Xen share a TLB tag with each other.
>>> > So the only time I see that we would have to flush all guest TLBs is
>>> > when the tag overflows and we start from 1 again. What am I missing
>>> > here?
>>>
>>> Oh, I see - this indeed looks to be quite a bit more flushing than is
>>> desirable. So the question, as you did put it already, is why it got
>>> done that way in the first place. At the very least it would look like
>>> more control would need to be given to the callers of both
>>> write_cr3() and flush_area_local(). Tim?
>>
>> IIRC:
>> - Remote TLB flushes are used for safety, e.g. to be sure that no
>> guest has a mapping of a page before its type or owner changes.
>> The callers rely on _all_ mappings of the page being gone after
>> the remote flush. The simplest way to do that is to flush all tags.
>
> Ah, of course. And that means that no matter that Tamas observed
> no breakage with some of the flushing removed, it can't be dropped
> altogether.
>
>> - We believed that on the then-current hardware, and with the
>> scheduling timeslice we had, there wasn't an awful lot of
>> benefit to keeping the tags of descheduled VMs around.
>> - Although it might sometimes be safe to leave some tags unflushed,
>> it wasn't clear exactly when that would be. E.g. I don't think
>> that whether the tag is 'current' is a very useful test -- either
>> the tag might contain dangerous mappings or it might not.
>>
>> Since there are cases where we already mask TLB flushes by domain
>> (usign the dirty-cpumask) I can see that we might pass that domain ID
>> to the remote CPU and drop only that domain's tags.
>>
>> And for HAP guests it may be possible to distinguish between "guest"
>> flushes (e.g. emulating guest CR3 writes) and "hypervisor" flushes
>> (e.g. after grant/p2m ops), and target "guest" flushes at particular
>> VCPUs.
>
> Right. Question is whether there are any such operations
> occurring frequently enough that optimizing this would make
> sense. I don't see HVM code paths leading to write_cr3(), and
> I don't think there are a whole lot leading to flush_area_local().
> Did you gain any insight in this regard, Tamas?
There are a ton of calls to flush_area_local, and a good chunk of them
with the idle vCPU being the active one when it is called. As for
write_cr3, there are also a lot of calls there. When I added some
debug output to observe just how many dom0 would take almost an hour
to boot and the serial line would just be spammed with that printk. So
even if there no HVM paths leading there, others paths definitely do
that affect HVM guests by making all of them take on a new tag next
time they are scheduled.
Tamas
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-10-07 15:41 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 17:29 Question about VPID during MOV-TO-CR3 Tamas K Lengyel
2016-09-21 10:23 ` Jan Beulich
2016-09-21 14:18 ` Tamas K Lengyel
2016-09-21 14:44 ` Jan Beulich
2016-09-21 15:09 ` Tamas K Lengyel
2016-09-21 15:16 ` Tamas K Lengyel
2016-09-21 15:23 ` Jan Beulich
2016-09-21 15:30 ` Tamas K Lengyel
2016-09-21 18:26 ` Tamas K Lengyel
2016-09-22 9:00 ` Jan Beulich
2016-09-22 10:39 ` Tamas K Lengyel
2016-09-22 11:35 ` Jan Beulich
2016-09-22 8:56 ` Jan Beulich
2016-09-22 10:35 ` Tamas K Lengyel
2016-09-22 11:27 ` Jan Beulich
2016-09-22 11:37 ` Tamas K Lengyel
2016-09-22 17:18 ` Tamas K Lengyel
2016-09-23 8:24 ` Jan Beulich
2016-09-23 8:35 ` Razvan Cojocaru
2016-09-23 15:26 ` Tamas K Lengyel
2016-09-23 15:39 ` Jan Beulich
2016-09-23 15:50 ` Tamas K Lengyel
2016-09-23 20:45 ` Tamas K Lengyel
2016-09-26 6:24 ` Jan Beulich
2016-09-26 16:12 ` Tamas K Lengyel
2016-09-27 13:49 ` Jan Beulich
2016-10-01 19:05 ` Tamas K Lengyel
2016-10-04 7:41 ` Jan Beulich
2016-10-04 14:12 ` Tamas K Lengyel
2016-10-04 14:29 ` Jan Beulich
2016-10-04 15:06 ` Tim Deegan
2016-10-07 15:32 ` Jan Beulich
2016-10-07 15:41 ` Tamas K Lengyel [this message]
2016-10-07 16:00 ` Jan Beulich
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=CAErYnshA8JceF+7dUiFSRqYHTfBVFhgojEuyut5tMevKQ+W-TQ@mail.gmail.com \
--to=tamas.lengyel@zentific.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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).