From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, yong.huang@smartx.com
Cc: qemu-devel@nongnu.org,
Richard Henderson <richard.henderson@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v4 5/6] migration: Support periodic RAMBlock dirty bitmap sync
Date: Thu, 17 Oct 2024 17:35:29 -0300 [thread overview]
Message-ID: <874j5a31ta.fsf@suse.de> (raw)
In-Reply-To: <ZxFmnZqgRlGaQax_@x1n>
Peter Xu <peterx@redhat.com> writes:
> On Thu, Oct 17, 2024 at 02:42:54PM +0800, yong.huang@smartx.com wrote:
>> +void cpu_throttle_dirty_sync_timer_tick(void *opaque)
>> +{
>> + static uint64_t prev_sync_cnt;
>
> We may need to reset this in case migration got cancelled and invoked
> again, to make sure it keeps working in the 2nd run.
>
>> + uint64_t sync_cnt = stat64_get(&mig_stats.dirty_sync_count);
>> +
>> + /*
>> + * The first iteration copies all memory anyhow and has no
>> + * effect on guest performance, therefore omit it to avoid
>> + * paying extra for the sync penalty.
>> + */
>> + if (sync_cnt <= 1) {
>> + goto end;
>> + }
>> +
>> + if (sync_cnt == prev_sync_cnt) {
>> + trace_cpu_throttle_dirty_sync();
>> + WITH_RCU_READ_LOCK_GUARD() {
>> + migration_bitmap_sync_precopy(false);
>> + }
>> + }
>> +
>> +end:
>> + prev_sync_cnt = stat64_get(&mig_stats.dirty_sync_count);
>> +
>> + timer_mod(throttle_dirty_sync_timer,
>> + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) +
>> + CPU_THROTTLE_DIRTY_SYNC_TIMESLICE_MS);
>> +}
>
> Please both of you have a look on whether you agree I squash below into
> this patch when merge:
>
> ===8<===
> From 84a2544eab73e35dbd35fed3b1440169915f9aa4 Mon Sep 17 00:00:00 2001
> From: Peter Xu <peterx@redhat.com>
> Date: Thu, 17 Oct 2024 15:27:19 -0400
> Subject: [PATCH] fixup! migration: Support periodic RAMBlock dirty bitmap sync
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> migration/cpu-throttle.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/migration/cpu-throttle.c b/migration/cpu-throttle.c
> index 342681cdd4..3df287d8d3 100644
> --- a/migration/cpu-throttle.c
> +++ b/migration/cpu-throttle.c
> @@ -36,6 +36,7 @@
> static QEMUTimer *throttle_timer, *throttle_dirty_sync_timer;
> static unsigned int throttle_percentage;
> static bool throttle_dirty_sync_timer_active;
> +static uint64_t throttle_dirty_sync_count_prev;
>
> #define CPU_THROTTLE_PCT_MIN 1
> #define CPU_THROTTLE_PCT_MAX 99
> @@ -133,7 +134,6 @@ int cpu_throttle_get_percentage(void)
>
> void cpu_throttle_dirty_sync_timer_tick(void *opaque)
> {
> - static uint64_t prev_sync_cnt;
> uint64_t sync_cnt = stat64_get(&mig_stats.dirty_sync_count);
>
> /*
> @@ -145,7 +145,7 @@ void cpu_throttle_dirty_sync_timer_tick(void *opaque)
> goto end;
> }
>
> - if (sync_cnt == prev_sync_cnt) {
> + if (sync_cnt == throttle_dirty_sync_count_prev) {
> trace_cpu_throttle_dirty_sync();
> WITH_RCU_READ_LOCK_GUARD() {
> migration_bitmap_sync_precopy(false);
> @@ -153,7 +153,7 @@ void cpu_throttle_dirty_sync_timer_tick(void *opaque)
> }
>
> end:
> - prev_sync_cnt = stat64_get(&mig_stats.dirty_sync_count);
> + throttle_dirty_sync_count_prev = stat64_get(&mig_stats.dirty_sync_count);
>
> timer_mod(throttle_dirty_sync_timer,
> qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) +
> @@ -171,6 +171,11 @@ void cpu_throttle_dirty_sync_timer(bool enable)
>
> if (enable) {
> if (!cpu_throttle_dirty_sync_active()) {
> + /*
> + * Always reset the dirty sync count cache, in case migration
> + * was cancelled once.
> + */
> + throttle_dirty_sync_count_prev = 0;
> timer_mod(throttle_dirty_sync_timer,
> qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) +
> CPU_THROTTLE_DIRTY_SYNC_TIMESLICE_MS);
> --
> 2.45.0
LGTM
next prev parent reply other threads:[~2024-10-17 20:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 6:42 [PATCH v4 0/6] migration: auto-converge refinements for huge VM yong.huang
2024-10-17 6:42 ` [PATCH v4 1/6] accel/tcg/icount-common: Remove the reference to the unused header file yong.huang
2024-10-17 17:59 ` Fabiano Rosas
2024-10-17 6:42 ` [PATCH v4 2/6] migration: Stop CPU throttling conditionally yong.huang
2024-10-17 18:02 ` Fabiano Rosas
2024-10-17 6:42 ` [PATCH v4 3/6] migration: Move cpu-throttole.c from system to migration yong.huang
2024-10-17 18:10 ` Fabiano Rosas
2024-10-17 6:42 ` [PATCH v4 4/6] migration: Remove "rs" parameter in migration_bitmap_sync_precopy yong.huang
2024-10-17 6:42 ` [PATCH v4 5/6] migration: Support periodic RAMBlock dirty bitmap sync yong.huang
2024-10-17 18:57 ` Fabiano Rosas
2024-10-17 19:33 ` Peter Xu
2024-10-17 20:35 ` Fabiano Rosas [this message]
2024-10-18 1:55 ` Yong Huang
2024-10-17 6:42 ` [PATCH v4 6/6] tests/migration: Add case for periodic ramblock dirty sync yong.huang
2024-10-17 19:01 ` Fabiano Rosas
2024-10-18 15:08 ` [PATCH v4 0/6] migration: auto-converge refinements for huge VM Peter Xu
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=874j5a31ta.fsf@suse.de \
--to=farosas@suse.de \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yong.huang@smartx.com \
/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.