All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyman Huang <huangy81@chinatelecom.cn>
To: Peter Xu <peterx@redhat.com>
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
	"David Hildenbrand" <david@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Markus ArmBruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH v14 3/7] migration/dirtyrate: Refactor dirty page rate calculation
Date: Mon, 14 Feb 2022 16:40:31 +0800	[thread overview]
Message-ID: <7ea51695-9590-bd9b-1d7d-49e8e5571f88@chinatelecom.cn> (raw)
In-Reply-To: <YgoLa4B7Eq8OOJq7@xz-m1.local>



在 2022/2/14 15:57, Peter Xu 写道:
> Mostly good, one trivial nit below:
> 
> On Fri, Feb 11, 2022 at 12:17:37AM +0800, huangy81@chinatelecom.cn wrote:
>> +int64_t vcpu_calculate_dirtyrate(int64_t calc_time_ms,
>> +                                 int64_t init_time_ms,
>> +                                 VcpuStat *stat,
>> +                                 unsigned int flag,
>> +                                 bool one_shot)
>> +{
>> +    DirtyPageRecord *records;
>> +    int64_t duration;
>> +    int64_t dirtyrate;
>> +    int i = 0;
>> +    unsigned int gen_id;
>> +
>> +retry:
>> +    cpu_list_lock();
>> +    gen_id = cpu_list_generation_id_get();
>> +    records = vcpu_dirty_stat_alloc(stat);
>> +    vcpu_dirty_stat_collect(stat, records, true);
>> +    cpu_list_unlock();
>> +
>> +    duration = dirty_stat_wait(calc_time_ms, init_time_ms);
> 
> Is it a must to pass in init_time_ms rather than always sleep in
> dirty_stat_wait()?  Could we simply drop it?
> 
Indeed, the parameter 'init_time_ms' seems kind of weird :(, we 
introduce 'init_time_ms' just becasue the calculate_dirtyrate_dirty_ring 
will call the function, see the following block:


  static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config)
  {
-    CPUState *cpu;
-    int64_t msec = 0;
      int64_t start_time;
+    int64_t duration;
      uint64_t dirtyrate = 0;
      uint64_t dirtyrate_sum = 0;
-    DirtyPageRecord *dirty_pages;
-    int nvcpu = 0;
      int i = 0;

-    CPU_FOREACH(cpu) {
-        nvcpu++;
-    }
-
-    dirty_pages = malloc(sizeof(*dirty_pages) * nvcpu);
-
-    DirtyStat.dirty_ring.nvcpu = nvcpu;
-    DirtyStat.dirty_ring.rates = malloc(sizeof(DirtyRateVcpu) * nvcpu);
-
-    dirtyrate_global_dirty_log_start();
-
-    CPU_FOREACH(cpu) {
-        record_dirtypages(dirty_pages, cpu, true);
-    }
+    /* start log sync */
+    global_dirty_log_change(GLOBAL_DIRTY_DIRTY_RATE, true);

      start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
      DirtyStat.start_time = start_time / 1000;

The reason why we introduce the 'init_time_ms' is wanting to store the
start_time info and display.

Dropping this parameter is fine from my point view if we ignore the 
duration error result from the delay between caller and callee of
'vcpu_calculate_dirtyrate’

-    msec = config.sample_period_seconds * 1000;
-    msec = set_sample_page_period(msec, start_time);
-    DirtyStat.calc_time = msec / 1000;
+    /* calculate vcpu dirtyrate */
+    duration = vcpu_calculate_dirtyrate(config.sample_period_seconds * 
1000,
+                                        start_time,
+                                        &DirtyStat.dirty_ring,
+                                        GLOBAL_DIRTY_DIRTY_RATE,
+                                        true);

-    dirtyrate_global_dirty_log_stop();
-
-    CPU_FOREACH(cpu) {
-        record_dirtypages(dirty_pages, cpu, false);
-    }
+    DirtyStat.calc_time = duration / 1000;




-- 
Best regard

Hyman Huang(黄勇)


  reply	other threads:[~2022-02-14  8:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 16:17 [PATCH v14 0/7] support dirty restraint on vCPU huangy81
2022-02-10 16:17 ` [PATCH v14 1/7] accel/kvm/kvm-all: Refactor per-vcpu dirty ring reaping huangy81
2022-02-14  7:57   ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 2/7] cpus: Introduce cpu_list_generation_id huangy81
2022-02-14  7:59   ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 3/7] migration/dirtyrate: Refactor dirty page rate calculation huangy81
2022-02-14  7:57   ` Peter Xu
2022-02-14  8:40     ` Hyman Huang [this message]
2022-02-14  9:47       ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 4/7] softmmu/dirtylimit: Implement vCPU dirtyrate calculation periodically huangy81
2022-02-14  8:01   ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 5/7] accel/kvm/kvm-all: Introduce kvm_dirty_ring_size function huangy81
2022-02-14  8:02   ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 6/7] softmmu/dirtylimit: Implement virtual CPU throttle huangy81
2022-02-14  8:20   ` Peter Xu
2022-02-14  9:05     ` Hyman Huang
2022-02-14  9:51       ` Peter Xu
2022-02-14  9:22     ` Hyman Huang
2022-02-10 16:17 ` [PATCH v14 7/7] softmmu/dirtylimit: Implement dirty page rate limit huangy81
2022-02-11 13:40   ` Markus Armbruster
2022-02-14  8:25   ` Peter Xu
2022-02-14  9:24     ` Hyman Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ea51695-9590-bd9b-1d7d-49e8e5571f88@chinatelecom.cn \
    --to=huangy81@chinatelecom.cn \
    --cc=armbru@redhat.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.