[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/10] migration/dirtyrate: Compare page hash results for reco
From: |
Chuan Zheng |
Subject: |
[PATCH v2 06/10] migration/dirtyrate: Compare page hash results for recorded sampled page |
Date: |
Sat, 15 Aug 2020 10:22:56 +0800 |
From: Zheng Chuan <zhengchuan@huawei.com>
Compare page hash results for recorded sampled page.
Signed-off-by: Zheng Chuan <zhengchuan@huawei.com>
Signed-off-by: YanYing Zhuang <ann.zhuangyanying@huawei.com>
---
migration/dirtyrate.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 11c0051..f136067 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -206,6 +206,79 @@ static int record_ramblock_hash_info(struct
DirtyRateConfig config,
return 0;
}
+static int calc_page_dirty_rate(struct RamblockDirtyInfo *info)
+{
+ uint8_t *md = NULL;
+ int i;
+ int ret = 0;
+
+ md = g_try_new0(uint8_t, qcrypto_hash_len);
+ if (!md)
+ return -1;
+
+ for (i = 0; i < info->sample_pages_count; i++) {
+ ret = get_ramblock_vfn_hash(info, info->sample_page_vfn[i], &md);
+ if (ret < 0) {
+ goto out;
+ }
+
+ if (memcmp(md, info->hash_result + i * qcrypto_hash_len,
qcrypto_hash_len) != 0) {
+ info->sample_dirty_count++;
+ }
+ }
+
+out:
+ g_free(md);
+ return ret;
+}
+
+static bool find_page_matched(RAMBlock *block, struct RamblockDirtyInfo *infos,
+ int count, struct RamblockDirtyInfo **matched)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (!strcmp(infos[i].idstr, qemu_ram_get_idstr(block))) {
+ break;
+ }
+ }
+
+ if (i == count) {
+ return false;
+ }
+
+ if (infos[i].ramblock_addr != qemu_ram_get_host_addr(block) ||
+ infos[i].ramblock_pages !=
+ (qemu_ram_get_used_length(block) >> 12)) {
+ return false;
+ }
+
+ *matched = &infos[i];
+ return true;
+}
+
+static int compare_page_hash_info(struct RamblockDirtyInfo *info, int
block_index)
+{
+ struct RamblockDirtyInfo *block_dinfo = NULL;
+ RAMBlock *block = NULL;
+
+ RAMBLOCK_FOREACH_MIGRATABLE(block) {
+ block_dinfo = NULL;
+ if (!find_page_matched(block, info, block_index + 1, &block_dinfo)) {
+ continue;
+ }
+ if (calc_page_dirty_rate(block_dinfo) < 0) {
+ return -1;
+ }
+ update_dirtyrate_stat(block_dinfo);
+ }
+ if (!dirty_stat.total_sample_count) {
+ return -1;
+ }
+
+ return 0;
+}
+
static void calculate_dirtyrate(struct DirtyRateConfig config)
{
/* todo */
--
1.8.3.1
- [PATCH v2 01/10] migration/dirtyrate: Add get_dirtyrate_thread() function, (continued)
- [PATCH v2 01/10] migration/dirtyrate: Add get_dirtyrate_thread() function, Chuan Zheng, 2020/08/14
- [PATCH v2 04/10] migration/dirtyrate: move RAMBLOCK_FOREACH_MIGRATABLE into ram.h, Chuan Zheng, 2020/08/14
- [PATCH v2 00/10] *** A Method for evaluating dirty page rate ***, Chuan Zheng, 2020/08/15
- [PATCH v2 02/10] migration/dirtyrate: Add RamlockDirtyInfo to store sampled page info, Chuan Zheng, 2020/08/15
- [PATCH v2 10/10] migration/dirtyrate: Implement qmp_cal_dirty_rate()/qmp_get_dirty_rate() function, Chuan Zheng, 2020/08/15
- [PATCH v2 09/10] migration/dirtyrate: Implement calculate_dirtyrate() function, Chuan Zheng, 2020/08/15
- [PATCH v2 08/10] migration/dirtyrate: Implement get_sample_page_period() and block_sample_page_period(), Chuan Zheng, 2020/08/15
- [PATCH v2 05/10] migration/dirtyrate: Record hash results for each sampled page, Chuan Zheng, 2020/08/15
- [PATCH v2 03/10] migration/dirtyrate: Add dirtyrate statistics series functions, Chuan Zheng, 2020/08/15
- [PATCH v2 04/10] migration/dirtyrate: move RAMBLOCK_FOREACH_MIGRATABLE into ram.h, Chuan Zheng, 2020/08/15
- [PATCH v2 06/10] migration/dirtyrate: Compare page hash results for recorded sampled page,
Chuan Zheng <=
- [PATCH v2 07/10] migration/dirtyrate: skip sampling ramblock with size below MIN_RAMBLOCK_SIZE, Chuan Zheng, 2020/08/15
- [PATCH v2 01/10] migration/dirtyrate: Add get_dirtyrate_thread() function, Chuan Zheng, 2020/08/15
- Re: [PATCH v2 00/10] *** A Method for evaluating dirty page rate ***, no-reply, 2020/08/15
- Re: [PATCH v2 00/10] *** A Method for evaluating dirty page rate ***, no-reply, 2020/08/15
- Re: [PATCH v2 00/10] *** A Method for evaluating dirty page rate ***, no-reply, 2020/08/15