[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 02/12] migration/dirtyrate: add DirtyRateStatus to denote
From: |
Li Qiang |
Subject: |
Re: [PATCH v7 02/12] migration/dirtyrate: add DirtyRateStatus to denote calculation status |
Date: |
Thu, 10 Sep 2020 22:27:52 +0800 |
Chuan Zheng <zhengchuan@huawei.com> 于2020年9月9日周三 下午10:08写道:
>
> add DirtyRateStatus to denote calculating status.
>
> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
> 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 bf7fd24..0a3350a 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 (atomic_cmpxchg(state, old_state, new_state) == old_state) {
> + return 0;
> + } else {
> + return -1;
> + }
> +}
> +
> +
> static void calculate_dirtyrate(struct DirtyRateConfig config)
> {
> /* todo */
> @@ -31,8 +44,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);
Doesn't need to check the 'ret'?
Just curious you checked other places but not here.
Thanks,
Li Qiang
> return NULL;
> }
> diff --git a/qapi/migration.json b/qapi/migration.json
> index 5f6b061..061ff25 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'] }
> --
> 1.8.3.1
>
>
- [PATCH v7 00/12] *** A Method for evaluating dirty page rate ***, Chuan Zheng, 2020/09/09
- [PATCH v7 03/12] migration/dirtyrate: Add RamblockDirtyInfo to store sampled page info, Chuan Zheng, 2020/09/09
- [PATCH v7 02/12] migration/dirtyrate: add DirtyRateStatus to denote calculation status, Chuan Zheng, 2020/09/09
- Re: [PATCH v7 02/12] migration/dirtyrate: add DirtyRateStatus to denote calculation status,
Li Qiang <=
- [PATCH v7 01/12] migration/dirtyrate: setup up query-dirtyrate framwork, Chuan Zheng, 2020/09/09
- [PATCH v7 04/12] migration/dirtyrate: Add dirtyrate statistics series functions, Chuan Zheng, 2020/09/09
- [PATCH v7 10/12] migration/dirtyrate: Implement calculate_dirtyrate() function, Chuan Zheng, 2020/09/09
- [PATCH v7 12/12] migration/dirtyrate: Add trace_calls to make it easier to debug, Chuan Zheng, 2020/09/09
- [PATCH v7 08/12] migration/dirtyrate: skip sampling ramblock with size below MIN_RAMBLOCK_SIZE, Chuan Zheng, 2020/09/09
- [PATCH v7 07/12] migration/dirtyrate: Compare page hash results for recorded sampled page, Chuan Zheng, 2020/09/09
- [PATCH v7 05/12] migration/dirtyrate: move RAMBLOCK_FOREACH_MIGRATABLE into ram.h, Chuan Zheng, 2020/09/09