[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/26] migration/dirtyrate: add DirtyRateStatus to denote calculat
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 04/26] migration/dirtyrate: add DirtyRateStatus to denote calculation status |
Date: |
Fri, 25 Sep 2020 13:06:33 +0100 |
From: Chuan Zheng <zhengchuan@huawei.com>
add DirtyRateStatus to denote calculating status.
Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Message-Id: <1600237327-33618-3-git-send-email-zhengchuan@huawei.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
atomic name fixup
---
migration/dirtyrate.c | 26 ++++++++++++++++++++++++++
qapi/migration.json | 17 +++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index bf7fd24e75..3edf000f45 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -22,6 +22,19 @@
#include "migration.h"
#include "dirtyrate.h"
+static int CalculatingState = DIRTY_RATE_STATUS_UNSTARTED;
+
+static int dirtyrate_set_state(int *state, int old_state, int new_state)
+{
+ assert(new_state < DIRTY_RATE_STATUS__MAX);
+ if (qatomic_cmpxchg(state, old_state, new_state) == old_state) {
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+
static void calculate_dirtyrate(struct DirtyRateConfig config)
{
/* todo */
@@ -31,8 +44,21 @@ static void calculate_dirtyrate(struct DirtyRateConfig
config)
void *get_dirtyrate_thread(void *arg)
{
struct DirtyRateConfig config = *(struct DirtyRateConfig *)arg;
+ int ret;
+
+ ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_UNSTARTED,
+ DIRTY_RATE_STATUS_MEASURING);
+ if (ret == -1) {
+ error_report("change dirtyrate state failed.");
+ return NULL;
+ }
calculate_dirtyrate(config);
+ ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_MEASURING,
+ DIRTY_RATE_STATUS_MEASURED);
+ if (ret == -1) {
+ error_report("change dirtyrate state failed.");
+ }
return NULL;
}
diff --git a/qapi/migration.json b/qapi/migration.json
index 675f70bb67..76a59b4f92 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1720,3 +1720,20 @@
##
{ 'event': 'UNPLUG_PRIMARY',
'data': { 'device-id': 'str' } }
+
+##
+# @DirtyRateStatus:
+#
+# An enumeration of dirtyrate status.
+#
+# @unstarted: the dirtyrate thread has not been started.
+#
+# @measuring: the dirtyrate thread is measuring.
+#
+# @measured: the dirtyrate thread has measured and results are available.
+#
+# Since: 5.2
+#
+##
+{ 'enum': 'DirtyRateStatus',
+ 'data': [ 'unstarted', 'measuring', 'measured'] }
--
2.26.2
- [PULL 00/26] migration and friends queue, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 01/26] migration: Properly destroy variables on incoming side, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 02/26] migration: Rework migrate_send_rp_req_pages() function, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 04/26] migration/dirtyrate: add DirtyRateStatus to denote calculation status,
Dr. David Alan Gilbert (git) <=
- [PULL 03/26] migration/dirtyrate: setup up query-dirtyrate framwork, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 05/26] migration/dirtyrate: Add RamblockDirtyInfo to store sampled page info, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 06/26] migration/dirtyrate: Add dirtyrate statistics series functions, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 07/26] migration/dirtyrate: move RAMBLOCK_FOREACH_MIGRATABLE into ram.h, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 08/26] migration/dirtyrate: Record hash results for each sampled page, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 09/26] migration/dirtyrate: Compare page hash results for recorded sampled page, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 10/26] migration/dirtyrate: skip sampling ramblock with size below MIN_RAMBLOCK_SIZE, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 11/26] migration/dirtyrate: Implement set_sample_page_period() and is_sample_period_valid(), Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 12/26] migration/dirtyrate: Implement calculate_dirtyrate() function, Dr. David Alan Gilbert (git), 2020/09/25
- [PULL 13/26] migration/dirtyrate: Implement qmp_cal_dirty_rate()/qmp_get_dirty_rate() function, Dr. David Alan Gilbert (git), 2020/09/25