In the cpu_physical_memory_sync_dirty_bitmap func, use start_global variable to make code more clear. And the addr variable is only used in slow path, so move it to slow path.
Signed-off-by: Keqian Zhu <zhukeqi...@huawei.com> --- include/exec/ram_addr.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 5e59a3d8d7..8311efb7bc 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -445,14 +445,13 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb, ram_addr_t length, uint64_t *real_dirty_pages) { - ram_addr_t addr; - unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS); + ram_addr_t start_global = start + rb->offset; + unsigned long word = BIT_WORD(start_global >> TARGET_PAGE_BITS); uint64_t num_dirty = 0; unsigned long *dest = rb->bmap; /* start address and length is aligned at the start of a word? */ - if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) == - (start + rb->offset) && + if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) == start_global && !(length & ((BITS_PER_LONG << TARGET_PAGE_BITS) - 1))) { int k; int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS); @@ -495,11 +494,11 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb, memory_region_clear_dirty_bitmap(rb->mr, start, length); } } else { - ram_addr_t offset = rb->offset; + ram_addr_t addr; for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) { if (cpu_physical_memory_test_and_clear_dirty( - start + addr + offset, + start_global + addr, TARGET_PAGE_SIZE, DIRTY_MEMORY_MIGRATION)) { *real_dirty_pages += 1; -- 2.19.1