[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 03/10] migration/dirtyrate: Add dirtyrate statistics serie
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH v3 03/10] migration/dirtyrate: Add dirtyrate statistics series functions |
Date: |
Thu, 20 Aug 2020 17:28:22 +0100 |
User-agent: |
Mutt/1.14.6 (2020-07-11) |
* Chuan Zheng (zhengchuan@huawei.com) wrote:
> Add dirtyrate statistics to record/update dirtyrate info.
>
> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
> Signed-off-by: YanYing Zhuang <ann.zhuangyanying@huawei.com>
> ---
> migration/dirtyrate.c | 30 ++++++++++++++++++++++++++++++
> migration/dirtyrate.h | 10 ++++++++++
> 2 files changed, 40 insertions(+)
>
> diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
> index bb0ebe9..8708090 100644
> --- a/migration/dirtyrate.c
> +++ b/migration/dirtyrate.c
> @@ -24,6 +24,7 @@
> #include "dirtyrate.h"
>
> CalculatingDirtyRateState CalculatingState = CAL_DIRTY_RATE_INIT;
> +static struct DirtyRateStat dirty_stat;
>
> static int dirty_rate_set_state(int new_state)
> {
> @@ -40,6 +41,35 @@ static int dirty_rate_set_state(int new_state)
> return 0;
> }
>
> +static void reset_dirtyrate_stat(void)
> +{
> + dirty_stat.total_dirty_samples = 0;
> + dirty_stat.total_sample_count = 0;
> + dirty_stat.total_block_mem_MB = 0;
> + dirty_stat.dirty_rate = 0;
> +}
> +
> +static void update_dirtyrate_stat(struct RamblockDirtyInfo *info)
> +{
> + dirty_stat.total_dirty_samples += info->sample_dirty_count;
> + dirty_stat.total_sample_count += info->sample_pages_count;
> + /* size of 4K pages in MB */
> + dirty_stat.total_block_mem_MB += info->ramblock_pages / 256;
> +}
> +
> +static void update_dirtyrate(uint64_t msec)
> +{
> + uint64_t dirty_rate;
> + unsigned int total_dirty_samples = dirty_stat.total_dirty_samples;
> + unsigned int total_sample_count = dirty_stat.total_sample_count;
> + size_t total_block_mem_MB = dirty_stat.total_block_mem_MB;
> +
> + dirty_rate = total_dirty_samples * total_block_mem_MB *
> + 1000 / (total_sample_count * msec);
> +
> + dirty_stat.dirty_rate = dirty_rate;
> +}
> +
> static void calculate_dirtyrate(struct DirtyRateConfig config)
> {
> /* todo */
> diff --git a/migration/dirtyrate.h b/migration/dirtyrate.h
> index 9650566..af57c80 100644
> --- a/migration/dirtyrate.h
> +++ b/migration/dirtyrate.h
> @@ -57,6 +57,16 @@ struct RamblockDirtyInfo {
> uint8_t *hash_result; /* array of hash result for sampled pages */
> };
>
> +/*
> + * Store calculate statistics for each measure.
> + */
> +struct DirtyRateStat {
> + unsigned int total_dirty_samples; /* total dirty pages for this measure
> */
> + unsigned int total_sample_count; /* total sampled pages for this measure
> */
> + size_t total_block_mem_MB; /* size of sampled pages in MB */
> + int64_t dirty_rate; /* dirty rate for this measure */
As I said in the previous review, please comment 'dirty_rate' with it's
units.
Dave
> +};
> +
> void *get_dirtyrate_thread(void *arg);
> #endif
>
> --
> 1.8.3.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
[PATCH v3 05/10] migration/dirtyrate: Record hash results for each sampled page, Chuan Zheng, 2020/08/16