All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gonglei <arei.gonglei@huawei.com>,
	Herongguang <herongguang.he@huawei.com>
Subject: [Qemu-devel] [PULL 04/11] memory: Don't update all memory region when ioeventfd changed
Date: Wed, 18 Jun 2014 15:42:01 +0200	[thread overview]
Message-ID: <1403098928-30749-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1403098928-30749-1-git-send-email-pbonzini@redhat.com>

From: Gonglei <arei.gonglei@huawei.com>

memory mappings don't rely on ioeventfds, there is no need
to destroy and rebuild them when manipulating ioeventfds,
otherwise it scarifies performance.

according to testing result, each ioeventfd deleing needs
about 5ms, within which memory mapping rebuilding needs
about 4ms. With many Nics and vmchannel in a VM doing migrating,
there can be many ioeventfds deleting which increasing
downtime remarkably.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Herongguang <herongguang.he@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 memory.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/memory.c b/memory.c
index 678661e..829d56d 100644
--- a/memory.c
+++ b/memory.c
@@ -28,6 +28,7 @@
 
 static unsigned memory_region_transaction_depth;
 static bool memory_region_update_pending;
+static bool ioeventfd_update_pending;
 static bool global_dirty_log = false;
 
 /* flat_view_mutex is taken around reading as->current_map; the critical
@@ -786,22 +787,34 @@ void memory_region_transaction_begin(void)
     ++memory_region_transaction_depth;
 }
 
+static void memory_region_clear_pending(void)
+{
+    memory_region_update_pending = false;
+    ioeventfd_update_pending = false;
+}
+
 void memory_region_transaction_commit(void)
 {
     AddressSpace *as;
 
     assert(memory_region_transaction_depth);
     --memory_region_transaction_depth;
-    if (!memory_region_transaction_depth && memory_region_update_pending) {
-        memory_region_update_pending = false;
-        MEMORY_LISTENER_CALL_GLOBAL(begin, Forward);
+    if (!memory_region_transaction_depth) {
+        if (memory_region_update_pending) {
+            MEMORY_LISTENER_CALL_GLOBAL(begin, Forward);
 
-        QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
-            address_space_update_topology(as);
-        }
+            QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
+                address_space_update_topology(as);
+            }
 
-        MEMORY_LISTENER_CALL_GLOBAL(commit, Forward);
-    }
+            MEMORY_LISTENER_CALL_GLOBAL(commit, Forward);
+        } else if (ioeventfd_update_pending) {
+            QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
+                address_space_update_ioeventfds(as);
+            }
+        }
+        memory_region_clear_pending();
+   }
 }
 
 static void memory_region_destructor_none(MemoryRegion *mr)
@@ -1373,7 +1386,7 @@ void memory_region_add_eventfd(MemoryRegion *mr,
     memmove(&mr->ioeventfds[i+1], &mr->ioeventfds[i],
             sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
     mr->ioeventfds[i] = mrfd;
-    memory_region_update_pending |= mr->enabled;
+    ioeventfd_update_pending |= mr->enabled;
     memory_region_transaction_commit();
 }
 
@@ -1406,7 +1419,7 @@ void memory_region_del_eventfd(MemoryRegion *mr,
     --mr->ioeventfd_nb;
     mr->ioeventfds = g_realloc(mr->ioeventfds,
                                   sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 1);
-    memory_region_update_pending |= mr->enabled;
+    ioeventfd_update_pending |= mr->enabled;
     memory_region_transaction_commit();
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2014-06-18 13:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 13:41 [Qemu-devel] [PULL 00/11] Memory API changes for 2014-06-18 Paolo Bonzini
2014-06-18 13:41 ` [Qemu-devel] [PULL 01/11] MAINTAINERS: Add myself as Memory API maintainer Paolo Bonzini
2014-06-18 13:41 ` [Qemu-devel] [PULL 02/11] exec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 03/11] unset RAMBlock idstr when unregister MemoryRegion Paolo Bonzini
2014-06-18 13:42 ` Paolo Bonzini [this message]
2014-06-18 13:42 ` [Qemu-devel] [PULL 05/11] memory: Simplify mr_add_subregion() if-else Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 06/11] exec: dummy_section: Pass address space through Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 07/11] qtest: fix qtest_clock_warp() for no deadline case Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 08/11] memory: MemoryRegion: factor out subregion add functionality Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 09/11] memory: MemoryRegion: factor out memory region re-adder Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 10/11] memory: MemoryRegion: rename parent to container Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 11/11] memory: Don't call memory_region_update_coalesced_range if nothing changed Paolo Bonzini
2014-06-18 15:28 ` [Qemu-devel] [PULL 00/11] Memory API changes for 2014-06-18 Peter Maydell

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=1403098928-30749-5-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=herongguang.he@huawei.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.