qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Rename cpu_get_icount_{locked,biased}
@ 2016-02-10 14:06 Christopher Covington
  2016-02-10 14:13 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Covington @ 2016-02-10 14:06 UTC (permalink / raw)
  Cc: Peter Maydell, Aaron Lindsay, qemu-trivial, Peter Crosthwaite,
	qemu-devel, Alistair Francis, Christopher Covington,
	Paolo Bonzini, Richard Henderson

The function does not provide locking but rather adds a bias value.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
---
 cpus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cpus.c b/cpus.c
index 898426c..50403c4 100644
--- a/cpus.c
+++ b/cpus.c
@@ -164,7 +164,7 @@ int64_t cpu_get_icount_raw(void)
 }
 
 /* Return the virtual CPU time, based on the instruction counter.  */
-static int64_t cpu_get_icount_locked(void)
+static int64_t cpu_get_icount_biased(void)
 {
     int64_t icount = cpu_get_icount_raw();
     return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount);
@@ -177,7 +177,7 @@ int64_t cpu_get_icount(void)
 
     do {
         start = seqlock_read_begin(&timers_state.vm_clock_seqlock);
-        icount = cpu_get_icount_locked();
+        icount = cpu_get_icount_biased();
     } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, start));
 
     return icount;
@@ -293,7 +293,7 @@ static void icount_adjust(void)
 
     seqlock_write_lock(&timers_state.vm_clock_seqlock);
     cur_time = cpu_get_clock_locked();
-    cur_icount = cpu_get_icount_locked();
+    cur_icount = cpu_get_icount_biased();
 
     delta = cur_icount - cur_time;
     /* FIXME: This is a very crude algorithm, somewhat prone to oscillation.  */
@@ -356,7 +356,7 @@ static void icount_warp_rt(void)
              * In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too
              * far ahead of real time.
              */
-            int64_t cur_icount = cpu_get_icount_locked();
+            int64_t cur_icount = cpu_get_icount_biased();
             int64_t delta = clock - cur_icount;
             warp_delta = MIN(warp_delta, delta);
         }
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] Rename cpu_get_icount_{locked,biased}
  2016-02-10 14:06 [Qemu-devel] [PATCH] Rename cpu_get_icount_{locked,biased} Christopher Covington
@ 2016-02-10 14:13 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2016-02-10 14:13 UTC (permalink / raw)
  To: Christopher Covington
  Cc: Aaron Lindsay, Peter Maydell, qemu-trivial, Peter Crosthwaite,
	qemu-devel, Alistair Francis, Richard Henderson



On 10/02/2016 15:06, Christopher Covington wrote:
> The function does not provide locking but rather adds a bias value.

"Locked" means that you need to take a look outside its call; see how
cpu_get_icount() uses it.

Basically the idea is that a "_locked" in the name warns you to pay
attention. :)

Paolo

> Signed-off-by: Christopher Covington <cov@codeaurora.org>
> ---
>  cpus.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 898426c..50403c4 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -164,7 +164,7 @@ int64_t cpu_get_icount_raw(void)
>  }
>  
>  /* Return the virtual CPU time, based on the instruction counter.  */
> -static int64_t cpu_get_icount_locked(void)
> +static int64_t cpu_get_icount_biased(void)
>  {
>      int64_t icount = cpu_get_icount_raw();
>      return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount);
> @@ -177,7 +177,7 @@ int64_t cpu_get_icount(void)
>  
>      do {
>          start = seqlock_read_begin(&timers_state.vm_clock_seqlock);
> -        icount = cpu_get_icount_locked();
> +        icount = cpu_get_icount_biased();
>      } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, start));
>  
>      return icount;
> @@ -293,7 +293,7 @@ static void icount_adjust(void)
>  
>      seqlock_write_lock(&timers_state.vm_clock_seqlock);
>      cur_time = cpu_get_clock_locked();
> -    cur_icount = cpu_get_icount_locked();
> +    cur_icount = cpu_get_icount_biased();
>  
>      delta = cur_icount - cur_time;
>      /* FIXME: This is a very crude algorithm, somewhat prone to oscillation.  */
> @@ -356,7 +356,7 @@ static void icount_warp_rt(void)
>               * In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too
>               * far ahead of real time.
>               */
> -            int64_t cur_icount = cpu_get_icount_locked();
> +            int64_t cur_icount = cpu_get_icount_biased();
>              int64_t delta = clock - cur_icount;
>              warp_delta = MIN(warp_delta, delta);
>          }
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-10 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-10 14:06 [Qemu-devel] [PATCH] Rename cpu_get_icount_{locked,biased} Christopher Covington
2016-02-10 14:13 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).