[PATCH] icount: fix shift=auto for record/replay

Pavel Dovgalyuk posted 1 patch 5 years, 5 months ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/158988500050.15192.692077802469400393.stgit@pasha-ThinkPad-X280
Maintainers: Richard Henderson <rth@twiddle.net>, Paolo Bonzini <pbonzini@redhat.com>
cpus.c |   20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
[PATCH] icount: fix shift=auto for record/replay
Posted by Pavel Dovgalyuk 5 years, 5 months ago
This patch fixes shift=auto when record/replay is enabled.
Now user does not need to guess the best shift value.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>

--

v2:
  moved icount_time_shift to vmstate subsection
---
 cpus.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 5670c96bcf..7ce0d569b3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -379,7 +379,8 @@ static void icount_adjust(void)
 
     seqlock_write_lock(&timers_state.vm_clock_seqlock,
                        &timers_state.vm_clock_lock);
-    cur_time = cpu_get_clock_locked();
+    cur_time = REPLAY_CLOCK_LOCKED(REPLAY_CLOCK_VIRTUAL_RT,
+                                   cpu_get_clock_locked());
     cur_icount = cpu_get_icount_locked();
 
     delta = cur_icount - cur_time;
@@ -647,6 +648,11 @@ static bool adjust_timers_state_needed(void *opaque)
     return s->icount_rt_timer != NULL;
 }
 
+static bool shift_state_needed(void *opaque)
+{
+    return use_icount == 2;
+}
+
 /*
  * Subsection for warp timer migration is optional, because may not be created
  */
@@ -674,6 +680,17 @@ static const VMStateDescription icount_vmstate_adjust_timers = {
     }
 };
 
+static const VMStateDescription icount_vmstate_shift = {
+    .name = "timer/icount/shift",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = shift_state_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT16(icount_time_shift, TimersState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 /*
  * This is a subsection for icount migration.
  */
@@ -690,6 +707,7 @@ static const VMStateDescription icount_vmstate_timers = {
     .subsections = (const VMStateDescription*[]) {
         &icount_vmstate_warp_timer,
         &icount_vmstate_adjust_timers,
+        &icount_vmstate_shift,
         NULL
     }
 };


Re: [PATCH] icount: fix shift=auto for record/replay
Posted by Paolo Bonzini 5 years, 5 months ago
On 19/05/20 12:43, Pavel Dovgalyuk wrote:
> This patch fixes shift=auto when record/replay is enabled.
> Now user does not need to guess the best shift value.
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>

Queued, thanks!

Paolo

> --
> 
> v2:
>   moved icount_time_shift to vmstate subsection
> ---
>  cpus.c |   20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 5670c96bcf..7ce0d569b3 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -379,7 +379,8 @@ static void icount_adjust(void)
>  
>      seqlock_write_lock(&timers_state.vm_clock_seqlock,
>                         &timers_state.vm_clock_lock);
> -    cur_time = cpu_get_clock_locked();
> +    cur_time = REPLAY_CLOCK_LOCKED(REPLAY_CLOCK_VIRTUAL_RT,
> +                                   cpu_get_clock_locked());
>      cur_icount = cpu_get_icount_locked();
>  
>      delta = cur_icount - cur_time;
> @@ -647,6 +648,11 @@ static bool adjust_timers_state_needed(void *opaque)
>      return s->icount_rt_timer != NULL;
>  }
>  
> +static bool shift_state_needed(void *opaque)
> +{
> +    return use_icount == 2;
> +}
> +
>  /*
>   * Subsection for warp timer migration is optional, because may not be created
>   */
> @@ -674,6 +680,17 @@ static const VMStateDescription icount_vmstate_adjust_timers = {
>      }
>  };
>  
> +static const VMStateDescription icount_vmstate_shift = {
> +    .name = "timer/icount/shift",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .needed = shift_state_needed,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_INT16(icount_time_shift, TimersState),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
>  /*
>   * This is a subsection for icount migration.
>   */
> @@ -690,6 +707,7 @@ static const VMStateDescription icount_vmstate_timers = {
>      .subsections = (const VMStateDescription*[]) {
>          &icount_vmstate_warp_timer,
>          &icount_vmstate_adjust_timers,
> +        &icount_vmstate_shift,
>          NULL
>      }
>  };
>