From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSxo-0004vJ-5L for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTSxe-0003bg-T2 for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:20 -0400 Received: from mail-ea0-x234.google.com ([2a00:1450:4013:c01::234]:42774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSxe-0003ba-Le for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:10 -0400 Received: by mail-ea0-f180.google.com with SMTP id h10so3840294eaj.11 for ; Tue, 08 Oct 2013 01:48:09 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 8 Oct 2013 10:47:34 +0200 Message-Id: <1381222058-16701-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1381222058-16701-1-git-send-email-pbonzini@redhat.com> References: <1381222058-16701-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 4/8] timers: reorganize icount_warp_rt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex@alex.org.uk To prepare for future code changes, move the increment of qemu_icount_bias outside the "if" statement. Also, hoist outside the if the check for timers that expired due to the "warping". The check is redundant when !runstate_is_running(), but doing it this way helps because the code that increments qemu_icount_bias will be a critical section. Signed-off-by: Paolo Bonzini --- cpus.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cpus.c b/cpus.c index f87ff6f..9f450ad 100644 --- a/cpus.c +++ b/cpus.c @@ -279,10 +279,10 @@ static void icount_warp_rt(void *opaque) if (runstate_is_running()) { int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - int64_t warp_delta = clock - vm_clock_warp_start; - if (use_icount == 1) { - qemu_icount_bias += warp_delta; - } else { + int64_t warp_delta; + + warp_delta = clock - vm_clock_warp_start; + if (use_icount == 2) { /* * In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too * far ahead of real time. @@ -290,13 +290,15 @@ static void icount_warp_rt(void *opaque) int64_t cur_time = cpu_get_clock(); int64_t cur_icount = cpu_get_icount(); int64_t delta = cur_time - cur_icount; - qemu_icount_bias += MIN(warp_delta, delta); - } - if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) { - qemu_clock_notify(QEMU_CLOCK_VIRTUAL); + warp_delta = MIN(warp_delta, delta); } + qemu_icount_bias += warp_delta; } vm_clock_warp_start = -1; + + if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) { + qemu_clock_notify(QEMU_CLOCK_VIRTUAL); + } } void qtest_clock_warp(int64_t dest) -- 1.8.3.1