diff mbox

[RFC,v6,08/32] icount: implement icount requesting

Message ID 20141208075345.7108.48047.stgit@PASHA-ISP
State New
Headers show

Commit Message

Pavel Dovgalyuk Dec. 8, 2014, 7:53 a.m. UTC
Replay uses number of executed instructions to determine corrent events
injection moments. This patch introduces new function for querying the
instructions counter.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 cpus.c               |   13 ++++++++++---
 include/qemu/timer.h |    1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

Comments

Paolo Bonzini Dec. 9, 2014, 5:39 p.m. UTC | #1
On 08/12/2014 08:53, Pavel Dovgalyuk wrote:
>          if (!cpu_can_do_io(cpu)) {
> -            fprintf(stderr, "Bad clock read\n");
> +            fprintf(stderr, "Bad icount read\n");
> +            exit(1);
>          }
>          icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
>      }
> +    return icount;
> +}
> +
> +/* Return the virtual CPU time, based on the instruction counter.  */
> +static int64_t cpu_get_icount_locked(void)
> +{
> +    int64_t icount = cpu_get_icount_raw();
>      return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount);

So it didn't work to set can_do_io?

Paolo
Paolo Bonzini Dec. 10, 2014, 7:41 a.m. UTC | #2
On 10/12/2014 07:35, Pavel Dovgalyuk wrote:
> No, it worked well and I deleted _nocache version of that function.
> But I still need _raw one to get the instructions counter.

Oh, great.  This patch can also go in early.

Paolo
Pavel Dovgalyuk Dec. 11, 2014, 8:16 a.m. UTC | #3
> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini
> On 10/12/2014 07:35, Pavel Dovgalyuk wrote:
> > No, it worked well and I deleted _nocache version of that function.
> > But I still need _raw one to get the instructions counter.
> 
> Oh, great.  This patch can also go in early.

What's the next? Will you upstream some of the patches to simplify reviewing of the others?

Pavel Dovgalyuk
Paolo Bonzini Dec. 11, 2014, 11:06 a.m. UTC | #4
On 11/12/2014 09:16, Pavel Dovgaluk wrote:
>>> > > No, it worked well and I deleted _nocache version of that function.
>>> > > But I still need _raw one to get the instructions counter.
>> > 
>> > Oh, great.  This patch can also go in early.
> What's the next? Will you upstream some of the patches to simplify reviewing of the others?

I'm waiting for Alex to review the PPC bits, but I've already queued these:

Paolo Bonzini (9):
      target-mips: kvm: do not use get_clock()

Pavel Dovgalyuk (8):
      cpu-exec: fix cpu_exec_nocache
      cpu-exec: reset exception_index correctly
      icount: set can_do_io outside TB execution
      icount: introduce cpu_get_icount_raw
      cpu-exec: invalidate nocache translation if they are interrupted
      timer: introduce new QEMU_CLOCK_VIRTUAL_RT clock
      cpus: make icount warp behave well with respect to stop/cont
      i386: do not cross the pages boundaries in replay mode

Also, more get_clock() changes were in Kevin's block pull request.

Paolo
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index 38af588..6602acc 100644
--- a/cpus.c
+++ b/cpus.c
@@ -136,8 +136,7 @@  typedef struct TimersState {
 
 static TimersState timers_state;
 
-/* Return the virtual CPU time, based on the instruction counter.  */
-static int64_t cpu_get_icount_locked(void)
+int64_t cpu_get_icount_raw(void)
 {
     int64_t icount;
     CPUState *cpu = current_cpu;
@@ -145,10 +144,18 @@  static int64_t cpu_get_icount_locked(void)
     icount = timers_state.qemu_icount;
     if (cpu) {
         if (!cpu_can_do_io(cpu)) {
-            fprintf(stderr, "Bad clock read\n");
+            fprintf(stderr, "Bad icount read\n");
+            exit(1);
         }
         icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
     }
+    return icount;
+}
+
+/* Return the virtual CPU time, based on the instruction counter.  */
+static int64_t cpu_get_icount_locked(void)
+{
+    int64_t icount = cpu_get_icount_raw();
     return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount);
 }
 
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 5f5210d..3dae414 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -743,6 +743,7 @@  static inline int64_t get_clock(void)
 #endif
 
 /* icount */
+int64_t cpu_get_icount_raw(void);
 int64_t cpu_get_icount(void);
 int64_t cpu_get_clock(void);
 int64_t cpu_get_clock_offset(void);