From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH RFC] kvm: add PV MMIO EVENTFD Date: Thu, 4 Apr 2013 14:04:42 +0300 Message-ID: <20130404110442.GA6467@redhat.com> References: <20130404104846.GA6227@redhat.com> <6D40C5F1-849E-4F32-B391-E1A1BFA8C59D@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <6D40C5F1-849E-4F32-B391-E1A1BFA8C59D@suse.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Alexander Graf Cc: Andrew Morton , x86@kernel.org, Will Deacon , linux-kernel@vger.kernel.org, Xiao Guangrong , Ingo Molnar , kvm@vger.kernel.org, "H. Peter Anvin" , Sasha Levin , Thomas Gleixner , Christoffer Dall , virtualization@lists.linux-foundation.org, Takuya Yoshikawa List-Id: virtualization@lists.linuxfoundation.org On Thu, Apr 04, 2013 at 01:57:34PM +0200, Alexander Graf wrote: > > On 04.04.2013, at 12:50, Michael S. Tsirkin wrote: > > > With KVM, MMIO is much slower than PIO, due to the need to > > do page walk and emulation. But with EPT, it does not have to be: we > > know the address from the VMCS so if the address is unique, we can look > > up the eventfd directly, bypassing emulation. > > > > Add an interface for userspace to specify this per-address, we can > > use this e.g. for virtio. > > > > The implementation adds a separate bus internally. This serves two > > purposes: > > - minimize overhead for old userspace that does not use PV MMIO > > - minimize disruption in other code (since we don't know the length, > > devices on the MMIO bus only get a valid address in write, this > > way we don't need to touch all devices to teach them handle > > an dinvalid length) > > > > At the moment, this optimization is only supported for EPT on x86 and > > silently ignored for NPT and MMU, so everything works correctly but > > slowly. > > > > TODO: NPT, MMU and non x86 architectures. > > > > The idea was suggested by Peter Anvin. Lots of thanks to Gleb for > > pre-review and suggestions. > > > > Signed-off-by: Michael S. Tsirkin > > This still uses page fault intercepts which are orders of magnitudes > slower than hypercalls. Not really. Here's a test: compare vmcall to portio: vmcall 1519 ... outl_to_kernel 1745 compare portio to mmio: mmio-wildcard-eventfd:pci-mem 3529 mmio-pv-eventfd:pci-mem 1878 portio-wildcard-eventfd:pci-io 1846 So not orders of magnitude. > Why don't you just create a PV MMIO hypercall > that the guest can use to invoke MMIO accesses towards the host based > on physical addresses with explicit length encodings? > That way you simplify and speed up all code paths, exceeding the speed > of PIO exits even. It should also be quite easily portable, as all > other platforms have hypercalls available as well. > > > Alex I sent such a patch, but maintainers seem reluctant to add hypercalls. Gleb, could you comment please? A fast way to do MMIO is probably useful in any case ... > Alex