qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: anthony@codemonkey.ws
Subject: [Qemu-devel] [PATCH 46/49] memory: move bitmap synchronization to its own function
Date: Mon, 13 Jan 2014 18:40:31 +0100	[thread overview]
Message-ID: <1389634834-24181-47-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1389634834-24181-1-git-send-email-quintela@redhat.com>

We want to have all the functions that handle directly the dirty
bitmap near.  We will change it later.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
---
 include/exec/ram_addr.h | 31 +++++++++++++++++++++++++++++++
 kvm-all.c               | 27 ++-------------------------
 2 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index db977fb..c6736ed 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -79,6 +79,37 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
     xen_modified_memory(start, length);
 }

+static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
+                                                          ram_addr_t start,
+                                                          ram_addr_t pages)
+{
+    unsigned int i, j;
+    unsigned long page_number, c;
+    hwaddr addr;
+    ram_addr_t ram_addr;
+    unsigned int len = (pages + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
+    unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;
+
+    /*
+     * bitmap-traveling is faster than memory-traveling (for addr...)
+     * especially when most of the memory is not dirty.
+     */
+    for (i = 0; i < len; i++) {
+        if (bitmap[i] != 0) {
+            c = leul_to_cpu(bitmap[i]);
+            do {
+                j = ffsl(c) - 1;
+                c &= ~(1ul << j);
+                page_number = (i * HOST_LONG_BITS + j) * hpratio;
+                addr = page_number * TARGET_PAGE_SIZE;
+                ram_addr = start + addr;
+                cpu_physical_memory_set_dirty_range(ram_addr,
+                                                    TARGET_PAGE_SIZE * hpratio);
+            } while (c != 0);
+        }
+    }
+}
+
 static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
                                                          ram_addr_t length,
                                                          unsigned client)
diff --git a/kvm-all.c b/kvm-all.c
index cb62ba4..0bfb060 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -380,33 +380,10 @@ static int kvm_set_migration_log(int enable)
 static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section,
                                          unsigned long *bitmap)
 {
-    unsigned int i, j;
-    unsigned long page_number, c;
-    hwaddr addr;
     ram_addr_t start = section->offset_within_region + section->mr->ram_addr;
-    ram_addr_t ram_addr;
-    unsigned int pages = int128_get64(section->size) / getpagesize();
-    unsigned int len = (pages + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
-    unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;
+    ram_addr_t pages = int128_get64(section->size) / getpagesize();

-    /*
-     * bitmap-traveling is faster than memory-traveling (for addr...)
-     * especially when most of the memory is not dirty.
-     */
-    for (i = 0; i < len; i++) {
-        if (bitmap[i] != 0) {
-            c = leul_to_cpu(bitmap[i]);
-            do {
-                j = ffsl(c) - 1;
-                c &= ~(1ul << j);
-                page_number = (i * HOST_LONG_BITS + j) * hpratio;
-                addr = page_number * TARGET_PAGE_SIZE;
-                ram_addr = start + addr;
-                cpu_physical_memory_set_dirty_range(ram_addr,
-                                                    TARGET_PAGE_SIZE * hpratio);
-            } while (c != 0);
-        }
-    }
+    cpu_physical_memory_set_dirty_lebitmap(bitmap, start, pages);
     return 0;
 }

-- 
1.8.4.2

  parent reply	other threads:[~2014-01-13 17:41 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 17:39 [Qemu-devel] [PULL 00/49] migration queue Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 01/49] avoid a bogus COMPLETED->CANCELLED transition Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 02/49] introduce MIG_STATE_CANCELLING state Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 03/49] migration: Fix rate limit Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 04/49] qemu-file: Make a few functions non-static Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 05/49] migration: Move QEMU_VM_* defines to migration/migration.h Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 06/49] savevm: Convert all tabs to spaces Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 07/49] savevm.c: Coding style fixes Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 08/49] savevm.c: Coding style fix Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 09/49] vmstate: Move VMState code to vmstate.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 10/49] qemu-file: Move QEMUFile code to qemu-file.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 11/49] savevm: Small comment about why timer QEMUFile/VMState code is in savevm.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 12/49] tests: Some unit tests for vmstate.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 13/49] bitmap: use long as index Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 14/49] memory: cpu_physical_memory_set_dirty_flags() result is never used Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 15/49] memory: cpu_physical_memory_set_dirty_range() return void Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 16/49] exec: use accessor function to know if memory is dirty Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 17/49] memory: create function to set a single dirty bit Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 18/49] exec: create function to get " Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 19/49] memory: make cpu_physical_memory_is_dirty return bool Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 20/49] memory: all users of cpu_physical_memory_get_dirty used only one flag Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 21/49] memory: set single dirty flags when possible Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 22/49] memory: cpu_physical_memory_set_dirty_range() always dirty all flags Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 23/49] memory: cpu_physical_memory_mask_dirty_range() always clears a single flag Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 24/49] memory: use bit 2 for migration Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 25/49] memory: make sure that client is always inside range Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 26/49] memory: only resize dirty bitmap when memory size increases Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 27/49] memory: cpu_physical_memory_clear_dirty_flag() result is never used Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 28/49] bitmap: Add bitmap_zero_extend operation Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 29/49] memory: split dirty bitmap into three Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 30/49] memory: unfold cpu_physical_memory_clear_dirty_flag() in its only user Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 31/49] memory: unfold cpu_physical_memory_set_dirty() " Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 32/49] memory: unfold cpu_physical_memory_set_dirty_flag() Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 33/49] memory: make cpu_physical_memory_get_dirty() the main function Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 34/49] memory: cpu_physical_memory_get_dirty() is used as returning a bool Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 35/49] memory: s/mask/clear/ cpu_physical_memory_mask_dirty_range Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 36/49] memory: use find_next_bit() to find dirty bits Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 37/49] memory: cpu_physical_memory_set_dirty_range() now uses bitmap operations Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 38/49] memory: cpu_physical_memory_clear_dirty_range() " Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 39/49] memory: s/dirty/clean/ in cpu_physical_memory_is_dirty() Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 40/49] memory: make cpu_physical_memory_reset_dirty() take a length parameter Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 41/49] memory: cpu_physical_memory_set_dirty_tracking() should return void Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 42/49] memory: split cpu_physical_memory_* functions to its own include Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 43/49] memory: unfold memory_region_test_and_clear() Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 44/49] kvm: use directly cpu_physical_memory_* api for tracking dirty pages Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 45/49] kvm: refactor start address calculation Juan Quintela
2014-01-13 17:40 ` Juan Quintela [this message]
2014-01-13 17:40 ` [Qemu-devel] [PATCH 47/49] memory: syncronize kvm bitmap using bitmaps operations Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 48/49] ram: split function that synchronizes a range Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 49/49] migration: synchronize memory bitmap 64bits at a time Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389634834-24181-47-git-send-email-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).