Skip to content

Commit fb61358

Browse files
Keqian Zhudagrh
authored andcommitted
migration: Count new_dirty instead of real_dirty
real_dirty_pages becomes equal to total ram size after dirty log sync in ram_init_bitmaps, the reason is that the bitmap of ramblock is initialized to be all set, so old path counts them as "real dirty" at beginning. This causes wrong dirty rate and false positive throttling. Signed-off-by: Keqian Zhu <[email protected]> Message-Id: <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]> Signed-off-by: Dr. David Alan Gilbert <[email protected]>
1 parent 617a32f commit fb61358

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

include/exec/ram_addr.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
442442
static inline
443443
uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
444444
ram_addr_t start,
445-
ram_addr_t length,
446-
uint64_t *real_dirty_pages)
445+
ram_addr_t length)
447446
{
448447
ram_addr_t addr;
449448
unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
@@ -469,7 +468,6 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
469468
if (src[idx][offset]) {
470469
unsigned long bits = atomic_xchg(&src[idx][offset], 0);
471470
unsigned long new_dirty;
472-
*real_dirty_pages += ctpopl(bits);
473471
new_dirty = ~dest[k];
474472
dest[k] |= bits;
475473
new_dirty &= bits;
@@ -502,7 +500,6 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
502500
start + addr + offset,
503501
TARGET_PAGE_SIZE,
504502
DIRTY_MEMORY_MIGRATION)) {
505-
*real_dirty_pages += 1;
506503
long k = (start + addr) >> TARGET_PAGE_BITS;
507504
if (!test_and_set_bit(k, dest)) {
508505
num_dirty++;

migration/ram.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,11 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
859859
/* Called with RCU critical section */
860860
static void ramblock_sync_dirty_bitmap(RAMState *rs, RAMBlock *rb)
861861
{
862-
rs->migration_dirty_pages +=
863-
cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length,
864-
&rs->num_dirty_pages_period);
862+
uint64_t new_dirty_pages =
863+
cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length);
864+
865+
rs->migration_dirty_pages += new_dirty_pages;
866+
rs->num_dirty_pages_period += new_dirty_pages;
865867
}
866868

867869
/**

0 commit comments

Comments
 (0)