From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSVRJ-0006wa-Kx for qemu-devel@nongnu.org; Tue, 25 Mar 2014 13:47:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSVQ8-0003rW-EH for qemu-devel@nongnu.org; Tue, 25 Mar 2014 13:45:58 -0400 Received: from greensocs.com ([178.33.234.66]:32943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSU25-0007PO-Is for qemu-devel@nongnu.org; Tue, 25 Mar 2014 12:16:57 -0400 From: fred.konrad@greensocs.com Date: Tue, 25 Mar 2014 17:16:34 +0100 Message-Id: <1395764200-7379-7-git-send-email-fred.konrad@greensocs.com> In-Reply-To: <1395764200-7379-1-git-send-email-fred.konrad@greensocs.com> References: <1395764200-7379-1-git-send-email-fred.konrad@greensocs.com> Subject: [Qemu-devel] [RFC PATCH v2 06/12] 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: pbonzini@redhat.com, mark.burton@greensocs.com, 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 4dced24..5df3106 100644 --- a/cpus.c +++ b/cpus.c @@ -1286,6 +1286,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); @@ -1302,6 +1303,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.8.1.4