Patchwork [27/30] ram: Use memory_region_test_and_clear_dirty

login
register
mail settings
Submitter Juan Quintela
Date Oct. 18, 2012, 7:30 a.m.
Message ID <1350545426-23172-28-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/192225/
State New
Headers show

Comments

Juan Quintela - Oct. 18, 2012, 7:30 a.m.
This avoids having to do two walks over the dirty bitmap, once reading
the dirty bits, and anthoer cleaning them.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Eric Blake - Oct. 18, 2012, 12:52 p.m.
On 10/18/2012 01:30 AM, Juan Quintela wrote:
> This avoids having to do two walks over the dirty bitmap, once reading
> the dirty bits, and anthoer cleaning them.

s/anthoer/another/

Patch

diff --git a/arch_init.c b/arch_init.c
index 6f39ebd..8391375 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -390,13 +390,12 @@  static void migration_bitmap_sync(void)

     QLIST_FOREACH(block, &ram_list.blocks, next) {
         for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
-            if (memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE,
-                                        DIRTY_MEMORY_MIGRATION)) {
+            if (memory_region_test_and_clear_dirty(block->mr,
+                                                   addr, TARGET_PAGE_SIZE,
+                                                   DIRTY_MEMORY_MIGRATION)) {
                 migration_bitmap_set_dirty(block->mr, addr);
             }
         }
-        memory_region_reset_dirty(block->mr, 0, block->length,
-                                  DIRTY_MEMORY_MIGRATION);
     }
     trace_migration_bitmap_sync_end(migration_dirty_pages
                                     - num_dirty_pages_init);