From: Paolo Bonzini <pbonzini@redhat.com>
To: fred.konrad@greensocs.com, qemu-devel@nongnu.org
Cc: mark.burton@greensocs.com
Subject: Re: [Qemu-devel] [RFC PATCH 01/12] icount: put icount variables into TimerState.
Date: Sat, 22 Mar 2014 09:58:15 +0100 [thread overview]
Message-ID: <532D50A7.8000403@redhat.com> (raw)
In-Reply-To: <1395429454-24690-2-git-send-email-fred.konrad@greensocs.com>
Il 21/03/2014 20:17, fred.konrad@greensocs.com ha scritto:
> From: KONRAD Frederic <fred.konrad@greensocs.com>
>
> This puts qemu_icount and qemu_icount_bias into TimerState structure to allow
> them to be migrated.
>
> Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
> ---
> cpus.c | 29 ++++++++++++++++-------------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 1104d61..687717f 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -100,17 +100,12 @@ static bool all_cpu_threads_idle(void)
>
> /* Protected by TimersState seqlock */
>
> -/* Compensate for varying guest execution speed. */
> -static int64_t qemu_icount_bias;
> static int64_t vm_clock_warp_start;
> /* Conversion factor from emulated instructions to virtual clock ticks. */
> static int icount_time_shift;
> /* Arbitrarily pick 1MIPS as the minimum allowable speed. */
> #define MAX_ICOUNT_SHIFT 10
>
> -/* Only written by TCG thread */
> -static int64_t qemu_icount;
> -
> static QEMUTimer *icount_rt_timer;
> static QEMUTimer *icount_vm_timer;
> static QEMUTimer *icount_warp_timer;
> @@ -127,6 +122,11 @@ typedef struct TimersState {
> int64_t cpu_clock_offset;
> int32_t cpu_ticks_enabled;
> int64_t dummy;
> +
> + /* Compensate for varying guest execution speed. */
> + int64_t qemu_icount_bias;
> + /* Only written by TCG thread */
> + int64_t qemu_icount;
> } TimersState;
>
> static TimersState timers_state;
> @@ -137,14 +137,14 @@ static int64_t cpu_get_icount_locked(void)
> int64_t icount;
> CPUState *cpu = current_cpu;
>
> - icount = qemu_icount;
> + icount = timers_state.qemu_icount;
> if (cpu) {
> if (!cpu_can_do_io(cpu)) {
> fprintf(stderr, "Bad clock read\n");
> }
> icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
> }
> - return qemu_icount_bias + (icount << icount_time_shift);
> + return timers_state.qemu_icount_bias + (icount << icount_time_shift);
> }
>
> int64_t cpu_get_icount(void)
> @@ -282,7 +282,8 @@ static void icount_adjust(void)
> icount_time_shift++;
> }
> last_delta = delta;
> - qemu_icount_bias = cur_icount - (qemu_icount << icount_time_shift);
> + timers_state.qemu_icount_bias = cur_icount
> + - (timers_state.qemu_icount << icount_time_shift);
> seqlock_write_unlock(&timers_state.vm_clock_seqlock);
> }
>
> @@ -331,7 +332,7 @@ static void icount_warp_rt(void *opaque)
> int64_t delta = cur_time - cur_icount;
> warp_delta = MIN(warp_delta, delta);
> }
> - qemu_icount_bias += warp_delta;
> + timers_state.qemu_icount_bias += warp_delta;
> }
> vm_clock_warp_start = -1;
> seqlock_write_unlock(&timers_state.vm_clock_seqlock);
> @@ -349,7 +350,7 @@ void qtest_clock_warp(int64_t dest)
> int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
> int64_t warp = MIN(dest - clock, deadline);
> seqlock_write_lock(&timers_state.vm_clock_seqlock);
> - qemu_icount_bias += warp;
> + timers_state.qemu_icount_bias += warp;
> seqlock_write_unlock(&timers_state.vm_clock_seqlock);
>
> qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL);
> @@ -1248,7 +1249,8 @@ static int tcg_cpu_exec(CPUArchState *env)
> int64_t count;
> int64_t deadline;
> int decr;
> - qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
> + timers_state.qemu_icount -= (cpu->icount_decr.u16.low
> + + cpu->icount_extra);
> cpu->icount_decr.u16.low = 0;
> cpu->icount_extra = 0;
> deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
> @@ -1263,7 +1265,7 @@ static int tcg_cpu_exec(CPUArchState *env)
> }
>
> count = qemu_icount_round(deadline);
> - qemu_icount += count;
> + timers_state.qemu_icount += count;
> decr = (count > 0xffff) ? 0xffff : count;
> count -= decr;
> cpu->icount_decr.u16.low = decr;
> @@ -1276,7 +1278,8 @@ static int tcg_cpu_exec(CPUArchState *env)
> if (use_icount) {
> /* Fold pending instructions back into the
> instruction counter, and clear the interrupt flag. */
> - qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
> + timers_state.qemu_icount -= (cpu->icount_decr.u16.low
> + + cpu->icount_extra);
> cpu->icount_decr.u32 = 0;
> cpu->icount_extra = 0;
> }
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2014-03-22 8:58 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-21 19:17 [Qemu-devel] [RFC PATCH 00/12] Reverse execution fred.konrad
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 01/12] icount: put icount variables into TimerState fred.konrad
2014-03-22 8:58 ` Paolo Bonzini [this message]
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 02/12] migration: migrate icount fields fred.konrad
2014-03-22 8:57 ` Paolo Bonzini
2014-03-24 14:49 ` Frederic Konrad
2014-03-24 15:42 ` Paolo Bonzini
2014-03-25 10:25 ` Frederic Konrad
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 03/12] migration: make qemu_savevm_state public fred.konrad
2014-03-21 19:54 ` Dr. David Alan Gilbert
2014-03-24 15:05 ` Frederic Konrad
2014-03-24 17:52 ` Dr. David Alan Gilbert
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 04/12] icount: introduce icount timer fred.konrad
2014-03-22 8:59 ` Paolo Bonzini
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 05/12] icount: check for icount clock deadline when cpu loop exits fred.konrad
2014-03-22 8:59 ` Paolo Bonzini
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 06/12] icount: make icount extra computed on icount clock as well fred.konrad
2014-03-22 9:00 ` Paolo Bonzini
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 07/12] timer: add cpu_icount_to_ns function fred.konrad
2014-03-22 9:00 ` Paolo Bonzini
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 08/12] introduce reverse execution mechanism fred.konrad
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 09/12] gdbstub: allow reverse execution in gdb stub fred.konrad
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 10/12] cpu-exec: trigger a debug request when rexec stops fred.konrad
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 11/12] cexe: synchronize icount on the next event fred.konrad
2014-03-21 19:17 ` [Qemu-devel] [RFC PATCH 12/12] cexe: allow to enable reverse execution fred.konrad
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=532D50A7.8000403@redhat.com \
--to=pbonzini@redhat.com \
--cc=fred.konrad@greensocs.com \
--cc=mark.burton@greensocs.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.