From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiAHx-0001qk-ST for qemu-devel@nongnu.org; Wed, 07 May 2014 18:26:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiAHp-00059b-Kb for qemu-devel@nongnu.org; Wed, 07 May 2014 18:26:09 -0400 Received: from mail.windriver.com ([147.11.1.11]:33687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiAHp-00059A-Bf for qemu-devel@nongnu.org; Wed, 07 May 2014 18:26:01 -0400 Message-ID: <536AB2EE.6010504@windriver.com> Date: Wed, 7 May 2014 16:25:50 -0600 From: Chris Friesen MIME-Version: 1.0 References: <53693FA4.3000306@windriver.com> <5369D504.2070101@redhat.com> In-Reply-To: <5369D504.2070101@redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] virtio-serial-pci very expensive during live migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org, armbru@redhat.com, amit.shah@redhat.com On 05/07/2014 12:39 AM, Paolo Bonzini wrote: > Il 06/05/2014 22:01, Chris Friesen ha scritto: >> >> It seems like the main problem is that we loop over all the queues, >> calling virtio_pci_set_host_notifier_internal() on each of them. That >> in turn calls memory_region_add_eventfd(), which calls >> memory_region_transaction_commit(), which scans over all the address >> spaces, which seems to take the vast majority of the time. > > Yes, you can wrap the entire loop with memory_region_transaction_begin > and memory_region_transaction_commit. Can you try that? I tried the patch below. Unfortunately it seems to cause qemu to crash. That said, I'm on a patched version so it might be good if someone else tried it. If it works for other people it might mean bugs in our other patches. Chris Index: qemu-1.4.2/hw/virtio-pci.c =================================================================== --- qemu-1.4.2.orig/hw/virtio-pci.c +++ qemu-1.4.2/hw/virtio-pci.c @@ -32,6 +32,7 @@ #include "virtio-pci.h" #include "qemu/range.h" #include "virtio-bus.h" +#include "exec/memory.h" /* from Linux's linux/virtio_pci.h */ @@ -209,6 +210,7 @@ static void virtio_pci_start_ioeventfd(V return; } + memory_region_transaction_begin(); for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { if (!virtio_queue_get_num(proxy->vdev, n)) { continue; @@ -219,10 +221,12 @@ static void virtio_pci_start_ioeventfd(V goto assign_error; } } + memory_region_transaction_commit(); proxy->ioeventfd_started = true; return; assign_error: + memory_region_transaction_commit(); while (--n >= 0) { if (!virtio_queue_get_num(proxy->vdev, n)) { continue; @@ -244,6 +248,7 @@ static void virtio_pci_stop_ioeventfd(Vi return; } + memory_region_transaction_begin(); for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { if (!virtio_queue_get_num(proxy->vdev, n)) { continue; @@ -252,6 +257,7 @@ static void virtio_pci_stop_ioeventfd(Vi r = virtio_pci_set_host_notifier_internal(proxy, n, false, false); assert(r >= 0); } + memory_region_transaction_commit(); proxy->ioeventfd_started = false; }