Skip to contentSkip to conversation

memory: add early bail out from cpu_physical_memory_set_dirty_range

PATCH In review Paolo Bonzini 2 participants 2 messages Jan 26, 2016 – Jan 28, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: add early bail out from cpu_physical_memory_set_dirty_range

This condition is true in the common case, so we can cut out the body of the function. In addition, this makes it easier for the compiler to do at least partial inlining, even if it decides that fully inlining the function is unreasonable.

---
 include/exec/ram_addr.h | 4 ++++
 1 file changed, 4 insertions(+)
include/exec/ram_addr.h +4 -0
index ef1489d..6e31fb5 100644
@@ -161,6 +161,10 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
     unsigned long end, page;
     unsigned long **d = ram_list.dirty_memory;
 
+    if (!mask && !xen_enabled()) {
+        return;
+    }
+
     end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
     page = start >> TARGET_PAGE_BITS;
     if (likely(mask & (1 << DIRTY_MEMORY_MIGRATION))) {
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Paolo Bonzini

This condition is true in the common case, so we can cut out the body of the function. In addition, this makes it easier for the compiler to do at least partial inlining, even if it decides that fully inlining the function is unreasonable.

---
 include/exec/ram_addr.h | 4 ++++
 1 file changed, 4 insertions(+)