Received: from eggs.gnu.org ([2001:4830:134:3::10]:40968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzozq-0001rI-PI for qemu-devel@nongnu.org; Wed, 25 Jun 2014 11:20:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wzozk-0003aW-Fb for qemu-devel@nongnu.org; Wed, 25 Jun 2014 11:20:26 -0400 Received: from greensocs.com ([178.33.234.66]:52672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzozk-0003aQ-9f for qemu-devel@nongnu.org; Wed, 25 Jun 2014 11:20:20 -0400 From: fred.konrad@greensocs.com Date: Wed, 25 Jun 2014 17:20:00 +0200 Message-Id: <1403709607-6434-7-git-send-email-fred.konrad@greensocs.com> In-Reply-To: <1403709607-6434-1-git-send-email-fred.konrad@greensocs.com> References: <1403709607-6434-1-git-send-email-fred.konrad@greensocs.com> Subject: [Qemu-devel] [RFC PATCH v5 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 dc2dc21..e90b9ff 100644 --- a/cpus.c +++ b/cpus.c @@ -1287,6 +1287,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); @@ -1303,6 +1304,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