[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 25/59] ram: Move migration_dirty_pages to RAMState
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 25/59] ram: Move migration_dirty_pages to RAMState |
Date: |
Wed, 19 Apr 2017 22:58:49 +0200 |
Signed-off-by: Juan Quintela <address@hidden>
Reviewed-by: Peter Xu <address@hidden>
---
migration/ram.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 88392e4..71f8ef3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -183,6 +183,8 @@ struct RAMState {
double xbzrle_cache_miss_rate;
/* xbzrle number of overflows */
uint64_t xbzrle_overflows;
+ /* number of dirty bits in the bitmap */
+ uint64_t migration_dirty_pages;
};
typedef struct RAMState RAMState;
@@ -223,8 +225,12 @@ uint64_t xbzrle_mig_pages_overflow(void)
return ram_state.xbzrle_overflows;
}
+static ram_addr_t ram_save_remaining(void)
+{
+ return ram_state.migration_dirty_pages;
+}
+
static QemuMutex migration_bitmap_mutex;
-static uint64_t migration_dirty_pages;
/* used by the search for pages to send */
struct PageSearchStatus {
@@ -582,7 +588,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs,
RAMBlock *rb,
return (next - base) << TARGET_PAGE_BITS;
}
-static inline bool migration_bitmap_clear_dirty(ram_addr_t addr)
+static inline bool migration_bitmap_clear_dirty(RAMState *rs, ram_addr_t addr)
{
bool ret;
int nr = addr >> TARGET_PAGE_BITS;
@@ -591,7 +597,7 @@ static inline bool migration_bitmap_clear_dirty(ram_addr_t
addr)
ret = test_and_clear_bit(nr, bitmap);
if (ret) {
- migration_dirty_pages--;
+ rs->migration_dirty_pages--;
}
return ret;
}
@@ -601,8 +607,9 @@ static void migration_bitmap_sync_range(RAMState *rs,
ram_addr_t start,
{
unsigned long *bitmap;
bitmap = atomic_rcu_read(&migration_bitmap_rcu)->bmap;
- migration_dirty_pages += cpu_physical_memory_sync_dirty_bitmap(bitmap,
- start, length, &rs->num_dirty_pages_period);
+ rs->migration_dirty_pages +=
+ cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length,
+ &rs->num_dirty_pages_period);
}
static void migration_bitmap_sync_init(RAMState *rs)
@@ -1304,7 +1311,7 @@ static int ram_save_target_page(RAMState *rs,
MigrationState *ms, QEMUFile *f,
int res = 0;
/* Check the pages is dirty and if it is send it */
- if (migration_bitmap_clear_dirty(dirty_ram_abs)) {
+ if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) {
unsigned long *unsentmap;
if (compression_switch && migrate_use_compression()) {
res = ram_save_compressed_page(rs, ms, f, pss,
@@ -1454,11 +1461,6 @@ void acct_update_position(QEMUFile *f, size_t size, bool
zero)
}
}
-static ram_addr_t ram_save_remaining(void)
-{
- return migration_dirty_pages;
-}
-
uint64_t ram_bytes_remaining(void)
{
return ram_save_remaining() * TARGET_PAGE_SIZE;
@@ -1532,6 +1534,7 @@ static void ram_state_reset(RAMState *rs)
void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)
{
+ RAMState *rs = &ram_state;
/* called in qemu main thread, so there is
* no writing race against this migration_bitmap
*/
@@ -1557,7 +1560,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t
new)
atomic_rcu_set(&migration_bitmap_rcu, bitmap);
qemu_mutex_unlock(&migration_bitmap_mutex);
- migration_dirty_pages += new - old;
+ rs->migration_dirty_pages += new - old;
call_rcu(old_bitmap, migration_bitmap_free, rcu);
}
}
@@ -1730,6 +1733,7 @@ static void postcopy_chunk_hostpages_pass(MigrationState
*ms, bool unsent_pass,
RAMBlock *block,
PostcopyDiscardState *pds)
{
+ RAMState *rs = &ram_state;
unsigned long *bitmap;
unsigned long *unsentmap;
unsigned int host_ratio = block->page_size / TARGET_PAGE_SIZE;
@@ -1827,7 +1831,7 @@ static void postcopy_chunk_hostpages_pass(MigrationState
*ms, bool unsent_pass,
* Remark them as dirty, updating the count for any pages
* that weren't previously dirty.
*/
- migration_dirty_pages += !test_and_set_bit(page, bitmap);
+ rs->migration_dirty_pages += !test_and_set_bit(page, bitmap);
}
}
@@ -2053,7 +2057,7 @@ static int ram_save_init_globals(RAMState *rs)
* Count the total number of pages used by ram blocks not including any
* gaps due to alignment or unplugs.
*/
- migration_dirty_pages = ram_bytes_total() >> TARGET_PAGE_BITS;
+ rs->migration_dirty_pages = ram_bytes_total() >> TARGET_PAGE_BITS;
memory_global_dirty_log_start();
migration_bitmap_sync(rs);
--
2.9.3
- [Qemu-devel] [PATCH 20/59] ram: Move xbzrle_bytes into RAMState, (continued)
- [Qemu-devel] [PATCH 20/59] ram: Move xbzrle_bytes into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 21/59] ram: Move xbzrle_pages into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 18/59] ram: Remove norm_mig_bytes_transferred, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 22/59] ram: Move xbzrle_cache_miss into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 23/59] ram: Move xbzrle_cache_miss_rate into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 26/59] ram: Everything was init to zero, so use memset, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 27/59] ram: Move migration_bitmap_mutex into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 24/59] ram: Move xbzrle_overflows into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 29/59] ram: Move bytes_transferred into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 28/59] ram: Move migration_bitmap_rcu into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 25/59] ram: Move migration_dirty_pages to RAMState,
Juan Quintela <=
- [Qemu-devel] [PATCH 30/59] ram: Use the RAMState bytes_transferred parameter, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 31/59] ram: Remove ram_save_remaining, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 32/59] ram: Move last_req_rb to RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 34/59] ram: Create ram_dirty_sync_count(), Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 33/59] ram: Move src_page_req* to RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 35/59] ram: Remove dirty_bytes_rate, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 37/59] ram: Move postcopy_requests into RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 36/59] ram: Move dirty_pages_rate to RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 38/59] ram: Add QEMUFile to RAMState, Juan Quintela, 2017/04/19
- [Qemu-devel] [PATCH 40/59] ram: Remove compression_switch and inline its logic, Juan Quintela, 2017/04/19