mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: Zachary Amsden <zach@vmware.com>
Cc: Andi Kleen <ak@suse.de>, Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Virtualization Mailing List <virtualization@lists.osdl.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Chris Wright <chrisw@sous-sol.org>, Avi Kivity <avi@qumranet.com>,
	Jeremy Fitzhardinge <jeremy@goop.org>
Subject: Re: [PATCH] Add I/O hypercalls for i386 paravirt
Date: Wed, 22 Aug 2007 19:59:18 +0200	[thread overview]
Message-ID: <20070822175918.GB8058@bingen.suse.de> (raw)
In-Reply-To: <46CC68D9.5060200@vmware.com>

On Wed, Aug 22, 2007 at 09:48:25AM -0700, Zachary Amsden wrote:
> Andi Kleen wrote:
> >On Tue, Aug 21, 2007 at 10:23:14PM -0700, Zachary Amsden wrote:
> >  
> >>In general, I/O in a virtual guest is subject to performance problems.  
> >>The I/O can not be completed physically, but must be virtualized.  This 
> >>means trapping and decoding port I/O instructions from the guest OS.  
> >>Not only is the trap for a #GP heavyweight, both in the processor and 
> >>the hypervisor (which usually has a complex #GP path), but this forces 
> >>the hypervisor to decode the individual instruction which has faulted.  
> >>    
> >
> >Is that really that expensive? Hard to imagine.
> >  
> 
> You have an expensive (16x cost of hypercall on some processors) 

Where is the difference comming from? Are you using SYSENTER
for the hypercall?  I can't really see you using SYSENTER,
because how would you do system calls then? I bet system calls
are more frequent than in/out, so if you have decide between the
two using them for syscalls is likely faster.

For an int XYZ gate i wouldn't expect that much difference to
a #GP fault.

Also I fail to see the fundamental speed difference between

mov index,register
int 0x...
...
switch (register) 
case xxxx: do emulation

versus

out ...
#gp
-> switch (*eip) {
case 0xee:  /* etc. */ 
	do emulation

> privilege transition, you have to decode the instruction, then you have 

out is usually a single byte. Shouldn't be very expensive
to decode. In fact it should be roughly equivalent to your
hypercall multiplex.

> to verify protection in the page tables mapping the page allows 
> execution (P, !NX, and U/S check).  This is a lot more expensive than a 

When the page is not executable or not present you get #PF not #GP. 
So the hardware already checks that.

The only case where you would need to check yourself is if you emulate
NX on non NX capable hardware, but I can't see you doing that.

> There are 24 different possible I/O operations; sometimes with a port 
> encoded in the instruction, sometimes with input in the DX register, 
> sometimes with a rep prefix, and for 3 different operand sizes.

Most of this is a single byte which is the same as the hypercall
demux. Essentially a table lookup if you use the obvious switch()

-Andi


  reply	other threads:[~2007-08-22 17:05 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-22  5:23 Zachary Amsden
2007-08-22  5:34 ` Avi Kivity
2007-08-22  5:40   ` Zachary Amsden
2007-08-22  8:37     ` Avi Kivity
2007-08-22 16:16       ` Zachary Amsden
2007-08-22  6:25   ` Rusty Russell
2007-08-22 10:35     ` Andi Kleen
2007-08-22  9:51       ` Avi Kivity
2007-08-22 11:08         ` Andi Kleen
2007-08-22 10:23           ` Avi Kivity
2007-08-22 11:23             ` Andi Kleen
2007-08-22 12:09               ` Avi Kivity
2007-08-22 13:15                 ` Andi Kleen
2007-08-22 12:32                   ` Avi Kivity
2007-08-22 16:11             ` Jeff Garzik
2007-08-27 17:54     ` Benjamin Herrenschmidt
2007-08-28  6:51       ` Zachary Amsden
2007-08-28 11:18         ` Benjamin Herrenschmidt
2007-08-22  6:00 ` H. Peter Anvin
2007-08-22  6:03   ` Zachary Amsden
2007-08-24 12:20     ` Pavel Machek
2007-08-22 10:22 ` Andi Kleen
2007-08-22 16:48   ` Zachary Amsden
2007-08-22 17:59     ` Andi Kleen [this message]
2007-08-22 17:07       ` Zachary Amsden
2007-08-22 19:46         ` Andi Kleen
2007-08-22 20:43           ` Zachary Amsden
2007-08-22 22:04             ` Andi Kleen
2007-08-22 21:25               ` Alan Cox
2007-08-22 21:41                 ` Zachary Amsden
2007-08-23  5:34                 ` Rusty Russell
2007-08-22 21:45               ` Zachary Amsden
2007-08-22 17:34       ` Alan Cox
2007-08-22 21:54 ` Jeremy Fitzhardinge
2007-08-22 22:15   ` James Courtier-Dutton
2007-08-22 22:20     ` Chris Wright
2007-08-22 22:29       ` James Courtier-Dutton
2007-08-22 22:34         ` Chris Wright
2007-08-22 23:14         ` Jeremy Fitzhardinge
2007-08-23  0:47           ` Andi Kleen
2007-08-23  0:38             ` Jeremy Fitzhardinge
2007-08-23  2:34               ` Andi Kleen
2007-08-27 17:54 ` Benjamin Herrenschmidt

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=20070822175918.GB8058@bingen.suse.de \
    --to=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=avi@qumranet.com \
    --cc=chrisw@sous-sol.org \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.osdl.org \
    --cc=zach@vmware.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

all inboxes | Powered by JetHome®