summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-09-14 12:16:20 +0300
committerAvi Kivity <avi@redhat.com>2011-12-05 12:04:09 +0200
commite87c099f1c9e461dcaa093b1b40b14e7e899e70f (patch)
tree24486d10a71baa1baec5c50c3838ab7f29868867 /memory.c
parent4703359e0eeb27c382fdf2951b842cf8bde26672 (diff)
downloadqemu-e87c099f1c9e461dcaa093b1b40b14e7e899e70f.tar.gz
qemu-e87c099f1c9e461dcaa093b1b40b14e7e899e70f.tar.bz2
qemu-e87c099f1c9e461dcaa093b1b40b14e7e899e70f.zip
memory: optimize empty transactions due to mutators
The mutating memory APIs can easily cause empty transactions, where the mutators don't actually change anything, or perhaps only modify disabled regions. Detect these conditions and avoid regenerating the memory topology. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/memory.c b/memory.c
index 7e842b3ad5..87639ab6ea 100644
--- a/memory.c
+++ b/memory.c
@@ -19,6 +19,7 @@
#include <assert.h>
unsigned memory_region_transaction_depth = 0;
+static bool memory_region_update_pending = false;
typedef struct AddrRange AddrRange;
@@ -757,6 +758,7 @@ static void address_space_update_topology(AddressSpace *as)
static void memory_region_update_topology(MemoryRegion *mr)
{
if (memory_region_transaction_depth) {
+ memory_region_update_pending |= !mr || mr->enabled;
return;
}
@@ -770,6 +772,8 @@ static void memory_region_update_topology(MemoryRegion *mr)
if (address_space_io.root) {
address_space_update_topology(&address_space_io);
}
+
+ memory_region_update_pending = false;
}
void memory_region_transaction_begin(void)
@@ -781,7 +785,9 @@ void memory_region_transaction_commit(void)
{
assert(memory_region_transaction_depth);
--memory_region_transaction_depth;
- memory_region_update_topology(NULL);
+ if (!memory_region_transaction_depth && memory_region_update_pending) {
+ memory_region_update_topology(NULL);
+ }
}
static void memory_region_destructor_none(MemoryRegion *mr)