]> Git Repo - qemu.git/commitdiff
exec: store RAMBlock pointer into memory region
authorGonglei <[email protected]>
Mon, 22 Feb 2016 08:34:55 +0000 (16:34 +0800)
committerPaolo Bonzini <[email protected]>
Thu, 25 Feb 2016 15:11:26 +0000 (16:11 +0100)
Each RAM memory region has a unique corresponding RAMBlock.
In the current realization, the memory region only stored
the ram_addr which means the offset of RAM address space,
We need to qurey the global ram.list to find the ram block
by ram_addr if we want to get the ram block, which is very
expensive.

Now, we store the RAMBlock pointer into memory region
structure. So, if we know the mr, we can easily get the
RAMBlock.

Signed-off-by: Gonglei <[email protected]>
Message-Id: <1456130097[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
exec.c
include/exec/memory.h
memory.c

diff --git a/exec.c b/exec.c
index 1f2450002bde41cc621f7b852e4cdd01db2e8e3b..4c0114a1a182931788f1fcb912f60ea5e81505a6 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -1717,6 +1717,8 @@ ram_addr_t qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
         error_propagate(errp, local_err);
         return -1;
     }
+
+    mr->ram_block = new_block;
     return addr;
 }
 
index c92734ae2bf853cc4a3d060348b5dfb4eb6a3257..683be46cd002a9a29f27601c2bd04bd955271383 100644 (file)
@@ -34,6 +34,7 @@
 #include "qapi/error.h"
 #include "qom/object.h"
 #include "qemu/rcu.h"
+#include "qemu/typedefs.h"
 
 #define MAX_PHYS_ADDR_SPACE_BITS 62
 #define MAX_PHYS_ADDR            (((hwaddr)1 << MAX_PHYS_ADDR_SPACE_BITS) - 1)
@@ -172,6 +173,7 @@ struct MemoryRegion {
     bool global_locking;
     uint8_t dirty_log_mask;
     ram_addr_t ram_addr;
+    RAMBlock *ram_block;
     Object *owner;
     const MemoryRegionIOMMUOps *iommu_ops;
 
index 09041edd437db20eb76148dfa296dc0e43d41f75..b4451dd2a59147cfaaaf0acfe37982b6b86a62fe 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -912,6 +912,7 @@ void memory_region_init(MemoryRegion *mr,
     }
     mr->name = g_strdup(name);
     mr->owner = owner;
+    mr->ram_block = NULL;
 
     if (name) {
         char *escaped_name = memory_region_escape_name(name);
This page took 0.038325 seconds and 4 git commands to generate.