public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: "Kapadia, Vivek" <Vivek.Kapadia@lsi.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: Event channels in KVM?
Date: Tue, 28 Apr 2009 11:59:56 -0500	[thread overview]
Message-ID: <49F7360C.8000308@codemonkey.ws> (raw)
In-Reply-To: <F4789BF54654AC44982AC0ED2DE2E64B2CD1E1F04E@inbmail01.lsi.com>

Kapadia, Vivek wrote:
> I came across this thread looking for an efficient event channel mechanism between two guests (running on different cpu cores).
>
> While I can use available emulated IO mechanism (guest1->host kernel driver->Qemu1->Qemu2) in conjunction with interrupt mechanism (Qemu2->host kernel driver->guest2) in KVM, this involves several context switches. Xen handles notifications in hypervisor via hypercall and hence is likely more efficient.
>   

They almost certainly aren't more efficient.

An event channel notification involves a hypercall to the hypervisor.  
When using VT, the performance difference between a vmcall exit vs. a 
pio exit is quite small (especially compared to the overhead of the 
exit).  We're talking in the order of nanoseconds compared to microseconds.

What makes KVM particularly different from Xen is that in KVM, the PIO 
operation results in a direct transition to QEMU.  In Xen, typically 
event channel notifications result in a bit being set in a bitmap which 
then results in an interrupt injection depending on the next opportunity 
the hypervisor has to schedule/run the receiving domain.  This is not 
deterministic and can potentially be a very long period of time.

Event channels are inherently asynchronous whereas PIO notifications in 
KVM are synchronous.  Since the scheduler isn't involved and control 
never leaves the CPU, the KVM PIO notifications are actually extremely 
efficient.  IMHO, it's one of KVM's best design features.

It used to be in HVM that since things like PIO operations are 
inherently synchronous, and there's not point in a VM waiting around for 
the asynchronous event channel notification to result in qemu-dm 
invocation,, there was a very special code path in the hypervisor to 
ensure that Domain-0 was scheduled immediately when receiving an event 
channel notification from an HVM domain.  This was an important 
optimization because event channel notification latency was 
prohibitively high.

Now in the context of the stub domain, I'm not sure what changes they've 
made.  In the earliest prototypes of stub domain, the same short cutting 
logic was maintained but the stub domain was executed instead of domain-0.

> Is there a way I can perform direct notification (guest1->host kernel driver->guest2) in kvm?
>   

Between guests, we don't have a notification framework today.  You can 
use IPC from two QEMU processes and I'd expect that to perform pretty 
well.  I'm not sure you can get much advantages from doing things in the 
kernel because you cannot avoid the heavy weight exit.

Regards,

Anthony Liguori

  reply	other threads:[~2009-04-28 16:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 16:39 Event channels in KVM? Kapadia, Vivek
2009-04-28 16:59 ` Anthony Liguori [this message]
2009-04-30  9:04   ` Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2008-09-19 17:16 Matt Anger
2008-09-19 18:31 ` Anthony Liguori
2008-09-19 19:10   ` Javier Guerra
2008-09-19 19:14     ` Anthony Liguori
2008-09-22 23:50       ` Matt Anger
2008-09-23  0:30         ` Dong, Eddie
2008-09-23  0:36           ` Matt Anger
2008-09-23  1:36             ` Dong, Eddie
2008-09-23  7:26         ` Avi Kivity

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=49F7360C.8000308@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=Vivek.Kapadia@lsi.com \
    --cc=kvm@vger.kernel.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