From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WziXr-0002HG-QD for qemu-devel@nongnu.org; Wed, 25 Jun 2014 04:27:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WziXl-0008IH-Ua for qemu-devel@nongnu.org; Wed, 25 Jun 2014 04:27:07 -0400 Received: from greensocs.com ([178.33.234.66]:50781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WziXl-0008I7-OT for qemu-devel@nongnu.org; Wed, 25 Jun 2014 04:27:01 -0400 From: fred.konrad@greensocs.com Date: Wed, 25 Jun 2014 10:26:41 +0200 Message-Id: <1403684808-23248-7-git-send-email-fred.konrad@greensocs.com> In-Reply-To: <1403684808-23248-1-git-send-email-fred.konrad@greensocs.com> References: <1403684808-23248-1-git-send-email-fred.konrad@greensocs.com> Subject: [Qemu-devel] [RFC PATCH v4 06/13] icount: make icount extra computed on icount clock as well. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, quintela@redhat.com, mark.burton@greensocs.com, dgilbert@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, vilanova@ac.upc.edu, fred.konrad@greensocs.com From: KONRAD Frederic This takes icount clock in account for icount extra computation so icount clock's timers will be triggered at the exact time. Signed-off-by: KONRAD Frederic Reviewed-by: Paolo Bonzini --- cpus.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpus.c b/cpus.c index 76de504..4b551f1 100644 --- a/cpus.c +++ b/cpus.c @@ -1288,6 +1288,7 @@ static int tcg_cpu_exec(CPUArchState *env) if (use_icount) { int64_t count; int64_t deadline; + int64_t icount_deadline; int decr; timers_state.qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); @@ -1304,6 +1305,15 @@ static int tcg_cpu_exec(CPUArchState *env) deadline = INT32_MAX; } + /* + * Take icount clock deadline in account too, and keep the nearest + * deadline. + */ + icount_deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_ICOUNT); + if ((icount_deadline >= 0) && (icount_deadline < deadline)) { + deadline = icount_deadline; + } + count = qemu_icount_round(deadline); timers_state.qemu_icount += count; decr = (count > 0xffff) ? 0xffff : count; -- 1.9.0