From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm/arm64: KVM: Perform local TLB invalidation when multiplexing vcpus on a single CPU
Date: Thu, 27 Oct 2016 11:51:26 +0100 [thread overview]
Message-ID: <20161027104925.GC27135@leverpostej> (raw)
In-Reply-To: <20161027100428.GA17829@cbox>
Hi Christoffer,
On Thu, Oct 27, 2016 at 12:04:28PM +0200, Christoffer Dall wrote:
> On Thu, Oct 27, 2016 at 10:49:00AM +0100, Marc Zyngier wrote:
> > The guest wouldn't have to do any invalidation at all on real HW,
> > because the TLBs are strictly private to a physical CPU (only the
> > invalidation can be broadcast to the Inner Shareable domain). But when
> > we multiplex two vcpus on the same physical CPU, we break the private
> > semantics, and a vcpu could hit in the TLB entries populated by the
> > another one.
>
> Such a guest would be using a mapping of the same VA with the same ASID
> on two separate CPUs, each pointing to a separate PA. If it ever were
> to, say, migrate a task, it would have to do invalidations then. Right?
An OS (not Linux) could use a different ASID space per-cpu.
e.g. with two single-threaded tasks A and B, you could have ASIDS:
cpu0 cpu1
A 0 1
B 1 0
... and this would not be a problem, so long as when mappings changed
maintenance were performed appropriately (e.g. perhaps it uses IPIs to
trigger the relevant local TLB invlidation, rather than using broadcast
ops).
> Does Linux or other guests actually do this?
Linux currently doesn't use ASIDs that way, but does use global mappings
in a potentially-confliciting way in the cold-return paths (hotplug-on
and return from idle). With two vCPUs, you could have a sequence like:
cpu0 cpu1
Task with ASID x started
hotplug on
install global TTBR0 mapping
global entry allocated into TLB
Task hits cpu1's global entry
... which cannot happen bare-metal, and there's no point at which the
guest can perform suitable maintenance.
> Another fix would be to allocate a VMID per VCPU I suppose, just to
> introduce a terrible TLB hit ratio :)
That would break broadcast invalidation within the guest, no?
... unless you also trapped all TLB maintenance, and did the IPI-based
broadcast in SW.
Thanks,
Mark.
next prev parent reply other threads:[~2016-10-27 10:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 15:31 [PATCH] arm/arm64: KVM: Perform local TLB invalidation when multiplexing vcpus on a single CPU Marc Zyngier
2016-10-24 16:16 ` Mark Rutland
2016-10-25 10:20 ` Marc Zyngier
2016-10-27 9:19 ` Christoffer Dall
2016-10-27 9:49 ` Marc Zyngier
2016-10-27 10:04 ` Christoffer Dall
2016-10-27 10:40 ` Marc Zyngier
2016-10-27 12:27 ` Christoffer Dall
2016-10-27 10:51 ` Mark Rutland [this message]
2016-10-27 12:28 ` Christoffer Dall
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=20161027104925.GC27135@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).