* [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate
@ 2017-03-14 1:55 Chao Fan
2017-03-14 8:38 ` Juan Quintela
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Chao Fan @ 2017-03-14 1:55 UTC (permalink / raw)
To: pbonzini, quintela, dgilbert, qemu-devel, berrange
Cc: caoj.fnst, douly.fnst, maozy.fnst, Chao Fan, Li Zhijian
In function cpu_physical_memory_sync_dirty_bitmap, file
include/exec/ram_addr.h:
if (src[idx][offset]) {
unsigned long bits = atomic_xchg(&src[idx][offset], 0);
unsigned long new_dirty;
new_dirty = ~dest[k];
dest[k] |= bits;
new_dirty &= bits;
num_dirty += ctpopl(new_dirty);
}
After these codes executed, only the pages not dirtied in bitmap(dest),
but dirtied in dirty_memory[DIRTY_MEMORY_MIGRATION] will be calculated.
For example:
When ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] = 0b00001111,
and atomic_rcu_read(&migration_bitmap_rcu)->bmap = 0b00000011,
the new_dirty will be 0b00001100, and this function will return 2 but not
4 which is expected.
the dirty pages in dirty_memory[DIRTY_MEMORY_MIGRATION] are all new,
so these should be calculated also.
Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
v2: Remove the parameter 'num_dirty_pages_init'
Fix incoming parameters of trace_migration_bitmap_sync_end
---
include/exec/ram_addr.h | 5 ++++-
migration/ram.c | 12 +++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index cd432e7..b05dc84 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -355,7 +355,8 @@ static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
static inline
uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,
ram_addr_t start,
- ram_addr_t length)
+ ram_addr_t length,
+ int64_t *real_dirty_pages)
{
ram_addr_t addr;
unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
@@ -379,6 +380,7 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,
if (src[idx][offset]) {
unsigned long bits = atomic_xchg(&src[idx][offset], 0);
unsigned long new_dirty;
+ *real_dirty_pages += ctpopl(bits);
new_dirty = ~dest[k];
dest[k] |= bits;
new_dirty &= bits;
@@ -398,6 +400,7 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,
start + addr,
TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION)) {
+ *real_dirty_pages += 1;
long k = (start + addr) >> TARGET_PAGE_BITS;
if (!test_and_set_bit(k, dest)) {
num_dirty++;
diff --git a/migration/ram.c b/migration/ram.c
index 719425b..de1e0a3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -576,18 +576,18 @@ static inline bool migration_bitmap_clear_dirty(ram_addr_t addr)
return ret;
}
+static int64_t num_dirty_pages_period;
static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
{
unsigned long *bitmap;
bitmap = atomic_rcu_read(&migration_bitmap_rcu)->bmap;
- migration_dirty_pages +=
- cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length);
+ migration_dirty_pages += cpu_physical_memory_sync_dirty_bitmap(bitmap,
+ start, length, &num_dirty_pages_period);
}
/* Fix me: there are too many global variables used in migration process. */
static int64_t start_time;
static int64_t bytes_xfer_prev;
-static int64_t num_dirty_pages_period;
static uint64_t xbzrle_cache_miss_prev;
static uint64_t iterations_prev;
@@ -620,7 +620,6 @@ uint64_t ram_pagesize_summary(void)
static void migration_bitmap_sync(void)
{
RAMBlock *block;
- uint64_t num_dirty_pages_init = migration_dirty_pages;
MigrationState *s = migrate_get_current();
int64_t end_time;
int64_t bytes_xfer_now;
@@ -646,9 +645,8 @@ static void migration_bitmap_sync(void)
rcu_read_unlock();
qemu_mutex_unlock(&migration_bitmap_mutex);
- trace_migration_bitmap_sync_end(migration_dirty_pages
- - num_dirty_pages_init);
- num_dirty_pages_period += migration_dirty_pages - num_dirty_pages_init;
+ trace_migration_bitmap_sync_end(num_dirty_pages_period);
+
end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
/* more than 1 second = 1000 millisecons */
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate
2017-03-14 1:55 [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate Chao Fan
@ 2017-03-14 8:38 ` Juan Quintela
2017-03-14 8:38 ` Juan Quintela
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Juan Quintela @ 2017-03-14 8:38 UTC (permalink / raw)
To: Chao Fan
Cc: pbonzini, dgilbert, qemu-devel, berrange, caoj.fnst, douly.fnst,
maozy.fnst, Li Zhijian
Chao Fan <fanc.fnst@cn.fujitsu.com> wrote:
> In function cpu_physical_memory_sync_dirty_bitmap, file
> include/exec/ram_addr.h:
>
> if (src[idx][offset]) {
> unsigned long bits = atomic_xchg(&src[idx][offset], 0);
> unsigned long new_dirty;
> new_dirty = ~dest[k];
> dest[k] |= bits;
> new_dirty &= bits;
> num_dirty += ctpopl(new_dirty);
> }
>
> After these codes executed, only the pages not dirtied in bitmap(dest),
> but dirtied in dirty_memory[DIRTY_MEMORY_MIGRATION] will be calculated.
> For example:
> When ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] = 0b00001111,
> and atomic_rcu_read(&migration_bitmap_rcu)->bmap = 0b00000011,
> the new_dirty will be 0b00001100, and this function will return 2 but not
> 4 which is expected.
> the dirty pages in dirty_memory[DIRTY_MEMORY_MIGRATION] are all new,
> so these should be calculated also.
#
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> ---
> v2: Remove the parameter 'num_dirty_pages_init'
> Fix incoming parameters of trace_migration_bitmap_sync_end
Reviewed-by: Juan Quintela <quintela@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate
2017-03-14 1:55 [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate Chao Fan
2017-03-14 8:38 ` Juan Quintela
@ 2017-03-14 8:38 ` Juan Quintela
2017-03-14 9:35 ` Chao Fan
2017-03-15 16:49 ` Juan Quintela
2017-03-16 7:58 ` Juan Quintela
3 siblings, 1 reply; 6+ messages in thread
From: Juan Quintela @ 2017-03-14 8:38 UTC (permalink / raw)
To: Chao Fan
Cc: pbonzini, dgilbert, qemu-devel, berrange, caoj.fnst, douly.fnst,
maozy.fnst, Li Zhijian
Chao Fan <fanc.fnst@cn.fujitsu.com> wrote:
> In function cpu_physical_memory_sync_dirty_bitmap, file
> include/exec/ram_addr.h:
>
> if (src[idx][offset]) {
> unsigned long bits = atomic_xchg(&src[idx][offset], 0);
> unsigned long new_dirty;
> new_dirty = ~dest[k];
> dest[k] |= bits;
> new_dirty &= bits;
> num_dirty += ctpopl(new_dirty);
> }
>
> After these codes executed, only the pages not dirtied in bitmap(dest),
> but dirtied in dirty_memory[DIRTY_MEMORY_MIGRATION] will be calculated.
> For example:
> When ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] = 0b00001111,
> and atomic_rcu_read(&migration_bitmap_rcu)->bmap = 0b00000011,
> the new_dirty will be 0b00001100, and this function will return 2 but not
> 4 which is expected.
> the dirty pages in dirty_memory[DIRTY_MEMORY_MIGRATION] are all new,
> so these should be calculated also.
#
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> ---
> v2: Remove the parameter 'num_dirty_pages_init'
> Fix incoming parameters of trace_migration_bitmap_sync_end
Reviewed-by: Juan Quintela <quintela@redhat.com>
Just curious, does this change show any difference in any load?
Later, Juan.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate
2017-03-14 8:38 ` Juan Quintela
@ 2017-03-14 9:35 ` Chao Fan
0 siblings, 0 replies; 6+ messages in thread
From: Chao Fan @ 2017-03-14 9:35 UTC (permalink / raw)
To: Juan Quintela
Cc: pbonzini, dgilbert, qemu-devel, berrange, caoj.fnst, douly.fnst,
maozy.fnst, Li Zhijian
On Tue, Mar 14, 2017 at 09:38:46AM +0100, Juan Quintela wrote:
>Chao Fan <fanc.fnst@cn.fujitsu.com> wrote:
>> In function cpu_physical_memory_sync_dirty_bitmap, file
>> include/exec/ram_addr.h:
>>
>> if (src[idx][offset]) {
>> unsigned long bits = atomic_xchg(&src[idx][offset], 0);
>> unsigned long new_dirty;
>> new_dirty = ~dest[k];
>> dest[k] |= bits;
>> new_dirty &= bits;
>> num_dirty += ctpopl(new_dirty);
>> }
>>
>> After these codes executed, only the pages not dirtied in bitmap(dest),
>> but dirtied in dirty_memory[DIRTY_MEMORY_MIGRATION] will be calculated.
>> For example:
>> When ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] = 0b00001111,
>> and atomic_rcu_read(&migration_bitmap_rcu)->bmap = 0b00000011,
>> the new_dirty will be 0b00001100, and this function will return 2 but not
>> 4 which is expected.
>> the dirty pages in dirty_memory[DIRTY_MEMORY_MIGRATION] are all new,
>> so these should be calculated also.
>#
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>>
>> ---
>> v2: Remove the parameter 'num_dirty_pages_init'
>> Fix incoming parameters of trace_migration_bitmap_sync_end
>
>Reviewed-by: Juan Quintela <quintela@redhat.com>
Hi Juan,
Thank you for your review!
>
>Just curious, does this change show any difference in any load?
I think this method can show the new dirty pages more precisely than
before, so it's helpful to determine the cpu throttle value.
You can see this mail:
https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg03479.html
And according to Daniel's suggestion, 'inst-dirty-pages-rate' in my
old patch isn't needed anymore after this patch:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg436183.html
Thanks,
Chao Fan
>
>Later, Juan.
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate
2017-03-14 1:55 [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate Chao Fan
2017-03-14 8:38 ` Juan Quintela
2017-03-14 8:38 ` Juan Quintela
@ 2017-03-15 16:49 ` Juan Quintela
2017-03-16 7:58 ` Juan Quintela
3 siblings, 0 replies; 6+ messages in thread
From: Juan Quintela @ 2017-03-15 16:49 UTC (permalink / raw)
To: Chao Fan
Cc: pbonzini, dgilbert, qemu-devel, berrange, caoj.fnst, douly.fnst,
maozy.fnst, Li Zhijian
Chao Fan <fanc.fnst@cn.fujitsu.com> wrote:
> In function cpu_physical_memory_sync_dirty_bitmap, file
> include/exec/ram_addr.h:
>
> if (src[idx][offset]) {
> unsigned long bits = atomic_xchg(&src[idx][offset], 0);
> unsigned long new_dirty;
> new_dirty = ~dest[k];
> dest[k] |= bits;
> new_dirty &= bits;
> num_dirty += ctpopl(new_dirty);
> }
>
> After these codes executed, only the pages not dirtied in bitmap(dest),
> but dirtied in dirty_memory[DIRTY_MEMORY_MIGRATION] will be calculated.
> For example:
> When ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] = 0b00001111,
> and atomic_rcu_read(&migration_bitmap_rcu)->bmap = 0b00000011,
> the new_dirty will be 0b00001100, and this function will return 2 but not
> 4 which is expected.
> the dirty pages in dirty_memory[DIRTY_MEMORY_MIGRATION] are all new,
> so these should be calculated also.
>
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> ---
> v2: Remove the parameter 'num_dirty_pages_init'
> Fix incoming parameters of trace_migration_bitmap_sync_end
Reviewed-by: Juan Quintela <quintela@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate
2017-03-14 1:55 [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate Chao Fan
` (2 preceding siblings ...)
2017-03-15 16:49 ` Juan Quintela
@ 2017-03-16 7:58 ` Juan Quintela
3 siblings, 0 replies; 6+ messages in thread
From: Juan Quintela @ 2017-03-16 7:58 UTC (permalink / raw)
To: Chao Fan
Cc: pbonzini, dgilbert, qemu-devel, berrange, caoj.fnst, douly.fnst,
maozy.fnst, Li Zhijian
Chao Fan <fanc.fnst@cn.fujitsu.com> wrote:
> In function cpu_physical_memory_sync_dirty_bitmap, file
> include/exec/ram_addr.h:
>
> if (src[idx][offset]) {
> unsigned long bits = atomic_xchg(&src[idx][offset], 0);
> unsigned long new_dirty;
> new_dirty = ~dest[k];
> dest[k] |= bits;
> new_dirty &= bits;
> num_dirty += ctpopl(new_dirty);
> }
>
> After these codes executed, only the pages not dirtied in bitmap(dest),
> but dirtied in dirty_memory[DIRTY_MEMORY_MIGRATION] will be calculated.
> For example:
> When ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] = 0b00001111,
> and atomic_rcu_read(&migration_bitmap_rcu)->bmap = 0b00000011,
> the new_dirty will be 0b00001100, and this function will return 2 but not
> 4 which is expected.
> the dirty pages in dirty_memory[DIRTY_MEMORY_MIGRATION] are all new,
> so these should be calculated also.
>
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> ---
> v2: Remove the parameter 'num_dirty_pages_init'
> Fix incoming parameters of trace_migration_bitmap_sync_end
queued
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-16 7:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-14 1:55 [Qemu-devel] [PATCH v2] Change the method to calculate dirty-pages-rate Chao Fan
2017-03-14 8:38 ` Juan Quintela
2017-03-14 8:38 ` Juan Quintela
2017-03-14 9:35 ` Chao Fan
2017-03-15 16:49 ` Juan Quintela
2017-03-16 7:58 ` Juan Quintela
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).