From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Event channels in KVM? Date: Thu, 30 Apr 2009 12:04:04 +0300 Message-ID: <49F96984.7040607@redhat.com> References: <49F7360C.8000308@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Kapadia, Vivek" , "kvm@vger.kernel.org" To: Anthony Liguori Return-path: Received: from mx2.redhat.com ([66.187.237.31]:52997 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbZD3JEN (ORCPT ); Thu, 30 Apr 2009 05:04:13 -0400 In-Reply-To: <49F7360C.8000308@codemonkey.ws> Sender: kvm-owner@vger.kernel.org List-ID: Anthony Liguori wrote: > 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. > If you make the pio operation wake up another guest, then the operation becomes asynchronous. There's really no fundamental different between Xen and kvm here, and both will require the same number of context switches (one) to transfer control. Handling a pio that is completely internal to the guest is different (Xen has to schedule dom0 or the stub domain), but that's not related to interguest communications. -- error compiling committee.c: too many arguments to function