From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZ6FF-0007OP-Vt for qemu-devel@nongnu.org; Sun, 05 May 2013 17:13:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZ6FD-0005aB-BS for qemu-devel@nongnu.org; Sun, 05 May 2013 17:13:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZ6FD-0005a5-3a for qemu-devel@nongnu.org; Sun, 05 May 2013 17:13:19 -0400 Date: Mon, 6 May 2013 00:13:07 +0300 From: "Michael S. Tsirkin" Message-ID: <20130505211307.GB7861@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] [KVM] Needless to update msi route when only msi-x entry "control" section changed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Zhanghaoyu (A)" Cc: "Huangweidong (C)" , Marcelo Tosatti , Luonengjun , qemu-devel , Zanghongyong , Qinchuanyu On Sat, May 04, 2013 at 09:12:30AM +0000, Zhanghaoyu (A) wrote: > With regard to old version linux guest(e.g., rhel-5.5), in ISR processing, mask and unmask msi-x vector every time, which result in VMEXIT, then QEMU will invoke kvm_irqchip_update_msi_route() to ask KVM hypervisor to update the VM irq routing table. In KVM hypervisor, synchronizing RCU needed after updating routing table, so much time consumed for waiting in wait_rcu_gp(). So CPU usage in VM is so high, while from the view of host, VM's total CPU usage is so low. > Masking/unmasking msi-x vector only set msi-x entry "control" section, needless to update VM irq routing table. > > Signed-off-by: Zhang Haoyu > Signed-off-by: Huang Weidong > Signed-off-by: Qin Chuanyu > --- > hw/i386/kvm/pci-assign.c | 3 +++ > 1 files changed, 3 insertions(+) > > --- a/hw/i386/kvm/pci-assign.c 2013-05-04 15:53:18.000000000 +0800 > +++ b/hw/i386/kvm/pci-assign.c 2013-05-04 15:50:46.000000000 +0800 > @@ -1576,6 +1576,8 @@ static void assigned_dev_msix_mmio_write > MSIMessage msg; > int ret; > > + /* Needless to update msi route when only msi-x entry "control" section changed */ > + if ((addr & (PCI_MSIX_ENTRY_SIZE - 1)) != PCI_MSIX_ENTRY_VECTOR_CTRL){ > msg.address = entry->addr_lo | > ((uint64_t)entry->addr_hi << 32); > msg.data = entry->data; > @@ -1585,6 +1587,7 @@ static void assigned_dev_msix_mmio_write > if (ret) { > error_report("Error updating irq routing entry (%d)", ret); > } > + } > } > } > } > > Thanks, > Zhang Haoyu If guest wants to update the vector, it does it like this: mask update unmask and it looks like the only point where we update the vector is on unmask, so this patch will mean we don't update the vector ever. I'm not sure this combination (old guest + legacy device assignment framework) is worth optimizing. Can you try VFIO instead? But if it is, the right way to do this is probably along the lines of the below patch. Want to try it out? diff --git a/kvm-all.c b/kvm-all.c index 2d92721..afe2327 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1006,6 +1006,11 @@ static int kvm_update_routing_entry(KVMState *s, continue; } + if (entry->type == new_entry->type && + entry->flags == new_entry->flags && + entry->u == new_entry->u) { + return 0; + } entry->type = new_entry->type; entry->flags = new_entry->flags; entry->u = new_entry->u; -- MST