Skip to contentSkip to conversation

memory: Don't call memory_region_update_coalesced_range if nothing changed

PATCH In review Fam Zheng 2 participants 2 messages Jun 13, 2014

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 memory: Don't call memory_region_update_coalesced_range if nothing changed

With huge number of PCI devices in the system (for example, 200 virtio-blk-pci), this unconditional call can slow down emulation of irrelevant PCI operations drastically, such as a BAR update on a device that has no coalescing region. So avoid it.

---
 memory.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
memory.c +6 -1
index d8ea212..57227f4 100644
@@ -1324,6 +1324,7 @@ void memory_region_add_coalescing(MemoryRegion *mr,
 void memory_region_clear_coalescing(MemoryRegion *mr)
 {
     CoalescedMemoryRange *cmr;
+    bool updated = false;
 
     qemu_flush_coalesced_mmio_buffer();
     mr->flush_coalesced_mmio = false;
@@ -1332,8 +1333,12 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
         cmr = QTAILQ_FIRST(&mr->coalesced);
         QTAILQ_REMOVE(&mr->coalesced, cmr, link);
         g_free(cmr);
+        updated = true;
+    }
+
+    if (updated) {
+        memory_region_update_coalesced_range(mr);
     }
-    memory_region_update_coalesced_range(mr);
 }
 
 void memory_region_set_flush_coalesced(MemoryRegion *mr)
Signature · 1 line
2.0.0
#1 lore raw

Il 13/06/2014 08:34, Fam Zheng ha scritto:

Quoted 27 lines

With huge number of PCI devices in the system (for example, 200 virtio-blk-pci), this unconditional call can slow down emulation of irrelevant PCI operations drastically, such as a BAR update on a device that has no coalescing region. So avoid it.

---
 memory.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
memory.c +1 -0
index d8ea212..57227f4 100644
@@ -1324,6 +1324,7 @@ void memory_region_add_coalescing(MemoryRegion *mr,
 void memory_region_clear_coalescing(MemoryRegion *mr)
 {
     CoalescedMemoryRange *cmr;
+    bool updated = false;
 
     qemu_flush_coalesced_mmio_buffer();
     mr->flush_coalesced_mmio = false;
@@ -1332,8 +1333,12 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
         cmr = QTAILQ_FIRST(&mr->coalesced);
         QTAILQ_REMOVE(&mr->coalesced, cmr, link);
         g_free(cmr);

memory.c void memory_region_clear_coalescing(MemoryRegion *mr) · line 1344

Quoted 10 lines
memory.c +5 -1
+        updated = true;
+    }
+
+    if (updated) {
+        memory_region_update_coalesced_range(mr);
     }
-    memory_region_update_coalesced_range(mr);
 }
 
 void memory_region_set_flush_coalesced(MemoryRegion *mr)

Very nice. Applying to memory branch, thank you.

Paolo