958e1b
From 67f736a89722dcaa425c70510c080e95216a165f Mon Sep 17 00:00:00 2001
2382db
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Thu, 19 Jun 2014 10:21:56 +0200
958e1b
Subject: [PATCH 11/13] memory: Don't call memory_region_update_coalesced_range if nothing changed
2382db
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1403173316-12035-1-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 59289
958e1b
O-Subject: [RHEL-7.1/7.0.z qemu-kvm PATCH] memory: Don't call memory_region_update_coalesced_range if nothing changed
958e1b
Bugzilla: 1096645
2382db
RH-Acked-by: Amos Kong <akong@redhat.com>
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
2382db
958e1b
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7596269
958e1b
BZ:   https://bugzilla.redhat.com/show_bug.cgi?id=1096645
2382db
2382db
With huge number of PCI devices in the system (for example, 200
2382db
virtio-blk-pci), this unconditional call can slow down emulation of
2382db
irrelevant PCI operations drastically, such as a BAR update on a device
2382db
that has no coalescing region. So avoid it.
2382db
2382db
Signed-off-by: Fam Zheng <famz@redhat.com>
2382db
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2382db
(cherry picked from commit ab5b3db5d711b290d63e954dc64647dd51cef962)
2382db
Signed-off-by: Fam Zheng <famz@redhat.com>
2382db
---
2382db
 memory.c | 7 ++++++-
2382db
 1 file changed, 6 insertions(+), 1 deletion(-)
2382db
2382db
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
2382db
---
2382db
 memory.c |    7 ++++++-
2382db
 1 files changed, 6 insertions(+), 1 deletions(-)
2382db
2382db
diff --git a/memory.c b/memory.c
2382db
index edaf6fd..a71d096 100644
2382db
--- a/memory.c
2382db
+++ b/memory.c
2382db
@@ -1210,6 +1210,7 @@ void memory_region_add_coalescing(MemoryRegion *mr,
2382db
 void memory_region_clear_coalescing(MemoryRegion *mr)
2382db
 {
2382db
     CoalescedMemoryRange *cmr;
2382db
+    bool updated = false;
2382db
 
2382db
     qemu_flush_coalesced_mmio_buffer();
2382db
     mr->flush_coalesced_mmio = false;
2382db
@@ -1218,8 +1219,12 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
2382db
         cmr = QTAILQ_FIRST(&mr->coalesced);
2382db
         QTAILQ_REMOVE(&mr->coalesced, cmr, link);
2382db
         g_free(cmr);
2382db
+        updated = true;
2382db
+    }
2382db
+
2382db
+    if (updated) {
2382db
+        memory_region_update_coalesced_range(mr);
2382db
     }
2382db
-    memory_region_update_coalesced_range(mr);
2382db
 }
2382db
 
2382db
 void memory_region_set_flush_coalesced(MemoryRegion *mr)
2382db
-- 
2382db
1.7.1
2382db