[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v4 07/25] icount: implement icount requestin
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC PATCH v4 07/25] icount: implement icount requesting |
Date: |
Fri, 07 Nov 2014 12:19:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
On 07/11/2014 11:32, Pavel Dovgalyuk wrote:
> 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 <address@hidden>
> ---
> cpus.c | 26 +++++++++++++++++++++++---
> include/qemu/timer.h | 1 +
> 2 files changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 7e8c507..2ec6d75 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)
> +static int64_t cpu_get_instructions_counter_locked(void)
> {
> int64_t icount;
> CPUState *cpu = current_cpu;
> @@ -145,10 +144,31 @@ 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;
> +}
> +
> +int64_t cpu_get_instructions_counter(void)
> +{
> + /* This function calls are synchnonized to timer changes,
> + calling cpu_get_instructions_counter_locked without lock is safe */
> + int64_t icount = timers_state.qemu_icount;
> + CPUState *cpu = current_cpu;
> +
> + if (cpu) {
> + icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
> + }
> + return icount;
> +}
This is the same as Frederic's QEMU_CLOCK_ICOUNT clock, right? Any
reason why one is better than the other?
Paolo
> +/* Return the virtual CPU time, based on the instruction counter. */
> +static int64_t cpu_get_icount_locked(void)
> +{
> + int64_t icount = cpu_get_instructions_counter_locked();
> 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..38a02c5 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_instructions_counter(void);
> int64_t cpu_get_icount(void);
> int64_t cpu_get_clock(void);
> int64_t cpu_get_clock_offset(void);
>
- Re: [Qemu-devel] [RFC PATCH v4 03/25] replay: global variables and function stubs, (continued)
[Qemu-devel] [RFC PATCH v4 08/25] icount: improve enable/disable ticks, Pavel Dovgalyuk, 2014/11/07
[Qemu-devel] [RFC PATCH v4 09/25] replay: introduce icount event, Pavel Dovgalyuk, 2014/11/07
[Qemu-devel] [RFC PATCH v4 10/25] i386: do not cross the pages boundaries in replay mode, Pavel Dovgalyuk, 2014/11/07