[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 02/12] migration/dirtyrate: add DirtyRateStatus to denote
From: |
Zheng Chuan |
Subject: |
Re: [PATCH v5 02/12] migration/dirtyrate: add DirtyRateStatus to denote calculation status |
Date: |
Thu, 27 Aug 2020 14:09:10 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
On 2020/8/26 19:49, Dr. David Alan Gilbert wrote:
> * Chuan Zheng (zhengchuan@huawei.com) wrote:
>> add DirtyRateStatus to denote calculating status.
>>
>> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
>
> With the minor wording changes from David Edmondson:
>
OK, will fix it in V6.
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
>> ---
>> migration/dirtyrate.c | 22 ++++++++++++++++++++++
>> qapi/migration.json | 17 +++++++++++++++++
>> 2 files changed, 39 insertions(+)
>>
>> diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
>> index 366f4e9..91987c5 100644
>> --- a/migration/dirtyrate.c
>> +++ b/migration/dirtyrate.c
>> @@ -23,6 +23,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 (atomic_cmpxchg(state, old_state, new_state) == old_state) {
>> + return 0;
>> + } else {
>> + return -1;
>> + }
>> +}
>> +
>> +
>> static void calculate_dirtyrate(struct DirtyRateConfig config)
>> {
>> /* todo */
>> @@ -32,8 +45,17 @@ 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) {
>> + return NULL;
>> + }
>>
>> calculate_dirtyrate(config);
>>
>> + ret = dirtyrate_set_state(&CalculatingState,
>> DIRTY_RATE_STATUS_MEASURING,
>> + DIRTY_RATE_STATUS_MEASURED);
>> return NULL;
>> }
>> diff --git a/qapi/migration.json b/qapi/migration.json
>> index 5f6b061..d640165 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: query-dirtyrate thread is not initial.
>> +#
>> +# @measuring: query-dirtyrate thread is created and start to measure.
>> +#
>> +# @measured: query-dirtyrate thread is end, we can get result.
>> +#
>> +# Since: 5.2
>> +#
>> +##
>> +{ 'enum': 'DirtyRateStatus',
>> + 'data': [ 'unstarted', 'measuring', 'measured'] }
>> --
>> 1.8.3.1
>>
[PATCH v5 08/12] migration/dirtyrate: skip sampling ramblock with size below MIN_RAMBLOCK_SIZE, Chuan Zheng, 2020/08/24
[PATCH v5 10/12] migration/dirtyrate: Implement calculate_dirtyrate() function, Chuan Zheng, 2020/08/24
[PATCH v5 09/12] migration/dirtyrate: Implement get_sample_page_period() and block_sample_page_period(), Chuan Zheng, 2020/08/24
[PATCH v5 11/12] migration/dirtyrate: Implement qmp_cal_dirty_rate()/qmp_get_dirty_rate() function, Chuan Zheng, 2020/08/24
[PATCH v5 05/12] migration/dirtyrate: move RAMBLOCK_FOREACH_MIGRATABLE into ram.h, Chuan Zheng, 2020/08/24
[PATCH v5 07/12] migration/dirtyrate: Compare page hash results for recorded sampled page, Chuan Zheng, 2020/08/24
[PATCH v5 12/12] migration/dirtyrate: Add trace_calls to make it easier to debug, Chuan Zheng, 2020/08/24