[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 2/3] memory: introduce DirtyRateDirtyPages and util function
From: |
huangy81 |
Subject: |
[PATCH v3 2/3] memory: introduce DirtyRateDirtyPages and util function |
Date: |
Thu, 15 Jul 2021 23:51:32 +0800 |
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
introduce DirtyRateDirtyPages and use it to the dirty pages
along with memory_global_dirty_log_sync.
introduce cpu_physical_memory_dirtyrate_reset_protect to
clear dirty bitmap within slot in kvm
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
include/exec/ram_addr.h | 19 +++++++++++++++++++
migration/dirtyrate.c | 2 ++
2 files changed, 21 insertions(+)
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 45c9132..dce0f46 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -26,6 +26,8 @@
#include "exec/ramlist.h"
#include "exec/ramblock.h"
+extern uint64_t DirtyRateDirtyPages;
+
/**
* clear_bmap_size: calculate clear bitmap size
*
@@ -415,6 +417,17 @@ static inline void
cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
}
}
}
+
+ if (global_dirty_tracking &&
+ global_dirty_tracking & GLOBAL_DIRTY_DIRTY_RATE) {
+ long nr = BITS_TO_LONGS(pages);
+ for (i = 0; i < nr; i++) {
+ if (bitmap[i]) {
+ unsigned long temp = leul_to_cpu(bitmap[i]);
+ DirtyRateDirtyPages += ctpopl(temp);
+ }
+ }
+ }
}
#endif /* not _WIN32 */
@@ -510,5 +523,11 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock
*rb,
return num_dirty;
}
+
+static inline
+void cpu_physical_memory_dirtyrate_reset_protect(RAMBlock *rb)
+{
+ memory_region_clear_dirty_bitmap(rb->mr, 0, rb->used_length);
+}
#endif
#endif
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 3c8c5e2..c465e62 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -28,6 +28,8 @@
#include "sysemu/runstate.h"
#include "exec/memory.h"
+uint64_t DirtyRateDirtyPages;
+
typedef struct DirtyPageRecord {
uint64_t start_pages;
uint64_t end_pages;
--
1.8.3.1