diff mbox

[3/8] timers: use cpu_get_icount() directly

Message ID 1381222058-16701-4-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Oct. 8, 2013, 8:47 a.m. UTC
This will help later when we will have to place these calls in
a critical section, and thus call a version of cpu_get_icount()
that does not take the lock.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 cpus.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Alex Bligh Oct. 8, 2013, 4:49 p.m. UTC | #1
On 8 Oct 2013, at 09:47, Paolo Bonzini wrote:

> This will help later when we will have to place these calls in
> a critical section, and thus call a version of cpu_get_icount()
> that does not take the lock.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-By: Alex Bligh <alex@alex.org.uk>

(and I meant Reviewed-By: in patches 1 and 2 - thanks Paolo
for setting me straight)

> ---
> cpus.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 870a832..f87ff6f 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -224,12 +224,15 @@ static void icount_adjust(void)
>     int64_t cur_icount;
>     int64_t delta;
>     static int64_t last_delta;
> +
>     /* If the VM is not running, then do nothing.  */
>     if (!runstate_is_running()) {
>         return;
>     }
> +
>     cur_time = cpu_get_clock();
> -    cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
> +    cur_icount = cpu_get_icount();
> +
>     delta = cur_icount - cur_time;
>     /* FIXME: This is a very crude algorithm, somewhat prone to oscillation.  */
>     if (delta > 0
> @@ -285,7 +288,7 @@ static void icount_warp_rt(void *opaque)
>              * far ahead of real time.
>              */
>             int64_t cur_time = cpu_get_clock();
> -            int64_t cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
> +            int64_t cur_icount = cpu_get_icount();
>             int64_t delta = cur_time - cur_icount;
>             qemu_icount_bias += MIN(warp_delta, delta);
>         }
> -- 
> 1.8.3.1
> 
> 
> 
>
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index 870a832..f87ff6f 100644
--- a/cpus.c
+++ b/cpus.c
@@ -224,12 +224,15 @@  static void icount_adjust(void)
     int64_t cur_icount;
     int64_t delta;
     static int64_t last_delta;
+
     /* If the VM is not running, then do nothing.  */
     if (!runstate_is_running()) {
         return;
     }
+
     cur_time = cpu_get_clock();
-    cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+    cur_icount = cpu_get_icount();
+
     delta = cur_icount - cur_time;
     /* FIXME: This is a very crude algorithm, somewhat prone to oscillation.  */
     if (delta > 0
@@ -285,7 +288,7 @@  static void icount_warp_rt(void *opaque)
              * far ahead of real time.
              */
             int64_t cur_time = cpu_get_clock();
-            int64_t cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+            int64_t cur_icount = cpu_get_icount();
             int64_t delta = cur_time - cur_icount;
             qemu_icount_bias += MIN(warp_delta, delta);
         }