From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Marc Zyngier <marc.zyngier@arm.com>, Mark Rutland <mark.rutland@arm.com>
Cc: kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH] KVM: ARM: updtae the VMID generation logic
Date: Fri, 30 Mar 2018 09:56:10 +0800 [thread overview]
Message-ID: <5ABD993A.8030100@huawei.com> (raw)
In-Reply-To: <861sg2su98.wl-marc.zyngier@arm.com>
On 2018/3/30 0:48, Marc Zyngier wrote:
> On Thu, 29 Mar 2018 16:27:58 +0100,
> Mark Rutland wrote:
>>
>> On Thu, Mar 29, 2018 at 11:00:24PM +0800, Shannon Zhao wrote:
>>> From: zhaoshenglong <zhaoshenglong@huawei.com>
>>>
>>> Currently the VMID for some VM is allocated during VCPU entry/exit
>>> context and will be updated when kvm_next_vmid inversion. So this will
>>> cause the existing VMs exiting from guest and flush the tlb and icache.
>>>
>>> Also, while a platform with 8 bit VMID supports 255 VMs, it can create
>>> more than 255 VMs and if we create e.g. 256 VMs, some VMs will occur
>>> page fault since at some moment two VMs have same VMID.
>>
>> Have you seen this happen?
>>
Yes, we've started 256 VMs on D05. We saw kernel page fault in some guests.
>> I beleive that update_vttbr() should prevent this. We intialize
>> kvm_vmid_gen to 1, and when we init a VM, we set its vmid_gen to 0. So
>> the first time a VM is scheduled, update_vttbr() will allocate a VMID,
>> and by construction we shouldn't be able to allocate the same VMID to
>> multiple active VMs, regardless of whether we overflow several
>> times.
>
> I remember testing that exact scenario when we implemented the VMID
> rollover a (long) while back. Maybe we've introduced a regression, but
> we're supposed to support 255 VMs running at the same time (which is
> not the same as having 255 VMs in total).
>
> Shannon: if you have observed such regression, please let us know.
>
Current approach could allow more than 255 VMs running at the same time.
It doesn't prevent the extra VMs creating. So at some moment, this will
be a race that two VMs have same VMID when there are more than 255 VMs.
>>
>>> This patch uses the bitmap to record which VMID used and available.
>>> Initialize the VMID and vttbr during creating the VM instead of VCPU
>>> entry/exit context. Also it will return error to user space if it wants
>>> to create VMs more than the supporting number.
>>
>> This creates a functional regression for anyone creating a large number
>> of VMs.
>
> Indeed, and I'm not buys that approach at all. As I said above, the
> intent is that we can have up to 2^VMID_SIZE-1 VMs running at the same
> time, and *any* number of VMs in the system.
>
I think it should not allow more than 255 VMs to create since if there
are 256 VMs, the VMs will not running properly and will fall in the loop
to update VMID.
>> If VMID overflow is a real bottleneck, it would be vastly better to
>> improve the VMID allocator along the lines of the arm64 ASID allocator,
>> so that upon overflow we reserve the set of active VMIDs (and therefore
>> avoid expensive TLB + icache maintenance). That does not require a
>> global limit on the number of VMs.
>
> +1.
>
I'll look at the ASID allocator approach.
Thanks,
--
Shannon
next prev parent reply other threads:[~2018-03-30 1:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 15:00 [PATCH] KVM: ARM: updtae the VMID generation logic Shannon Zhao
2018-03-29 15:27 ` Mark Rutland
2018-03-29 16:48 ` Marc Zyngier
2018-03-30 1:56 ` Shannon Zhao [this message]
2018-03-30 9:01 ` Marc Zyngier
2018-03-30 9:52 ` Shannon Zhao
2018-03-30 10:48 ` Marc Zyngier
2018-03-30 13:42 ` Shannon Zhao
2018-03-30 16:13 ` Marc Zyngier
2018-04-03 16:49 ` Mark Rutland
2018-04-04 8:43 ` Marc Zyngier
2018-04-04 15:26 ` Marc Zyngier
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=5ABD993A.8030100@huawei.com \
--to=zhaoshenglong@huawei.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.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.