All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Some optimization in dirty bitmap sync
@ 2020-03-10  9:17 Keqian Zhu
  2020-03-10  9:17 ` [PATCH v2 1/2] memory: Introduce start_global variable " Keqian Zhu
  2020-03-10  9:17 ` [PATCH v2 2/2] migration: not require length align when choose fast dirty sync path Keqian Zhu
  0 siblings, 2 replies; 3+ messages in thread
From: Keqian Zhu @ 2020-03-10  9:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Keqian Zhu, Dr . David Alan Gilbert,
	wanghaibin.wang

This patch series including code style change and performace fix
about dirty bitmap sync.

---
changelogs:

v2:
 - split code style change and performace fix.

Keqian Zhu (2):
  memory: Introduce start_global variable in dirty bitmap sync
  migration: not require length align when choose fast dirty sync path

 include/exec/ram_addr.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

-- 
2.19.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] memory: Introduce start_global variable in dirty bitmap sync
  2020-03-10  9:17 [PATCH v2 0/2] Some optimization in dirty bitmap sync Keqian Zhu
@ 2020-03-10  9:17 ` Keqian Zhu
  2020-03-10  9:17 ` [PATCH v2 2/2] migration: not require length align when choose fast dirty sync path Keqian Zhu
  1 sibling, 0 replies; 3+ messages in thread
From: Keqian Zhu @ 2020-03-10  9:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Keqian Zhu, Dr . David Alan Gilbert,
	wanghaibin.wang

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 <zhukeqian1@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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] migration: not require length align when choose fast dirty sync path
  2020-03-10  9:17 [PATCH v2 0/2] Some optimization in dirty bitmap sync Keqian Zhu
  2020-03-10  9:17 ` [PATCH v2 1/2] memory: Introduce start_global variable " Keqian Zhu
@ 2020-03-10  9:17 ` Keqian Zhu
  1 sibling, 0 replies; 3+ messages in thread
From: Keqian Zhu @ 2020-03-10  9:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Keqian Zhu, Dr . David Alan Gilbert,
	wanghaibin.wang

In commit aa777e297c84 ("cpu_physical_memory_sync_dirty_bitmap: Another
alignment fix"), ramblock length is required to align word pages when
we choose the fast dirty sync path. The reason is that "If the Ramblock
is less than 64 pages in length that long can contain bits representing
two different RAMBlocks, but the code will update the bmap belinging to
the 1st RAMBlock only while having updated the total dirty page count
for both."

This is right before commit 801110ab22be ("find_ram_offset: Align
ram_addr_t allocation on long boundaries"), which align ram_addr_t
allocation on long boundaries. So currently we wont "updated the total
dirty page count for both".

By removing the alignment constraint of length in fast path, we can always
use fast dirty sync path if start_global is aligned to word page.

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
---
 include/exec/ram_addr.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 8311efb7bc..57b3edf376 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -450,9 +450,8 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
     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_global &&
-        !(length & ((BITS_PER_LONG << TARGET_PAGE_BITS) - 1))) {
+    /* start address is aligned at the start of a word? */
+    if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) == start_global) {
         int k;
         int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS);
         unsigned long * const *src;
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-10  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10  9:17 [PATCH v2 0/2] Some optimization in dirty bitmap sync Keqian Zhu
2020-03-10  9:17 ` [PATCH v2 1/2] memory: Introduce start_global variable " Keqian Zhu
2020-03-10  9:17 ` [PATCH v2 2/2] migration: not require length align when choose fast dirty sync path Keqian Zhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.