Received: from eggs.gnu.org ([2001:4830:134:3::10]:42668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzmKs-0004lt-Rt for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:11:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzmKn-0007jZ-W8 for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:11:18 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:38688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bzmKn-0007i6-OX for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:11:13 -0400 Received: by mail-wm0-x233.google.com with SMTP id n67so50405003wme.1 for ; Thu, 27 Oct 2016 08:11:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 27 Oct 2016 16:10:14 +0100 Message-Id: <20161027151030.20863-18-alex.bennee@linaro.org> In-Reply-To: <20161027151030.20863-1-alex.bennee@linaro.org> References: <20161027151030.20863-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v5 17/33] cpus: re-factor out handle_icount_deadline List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com, mark.burton@greensocs.com, jan.kiszka@siemens.com, serge.fdrv@gmail.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Crosthwaite In preparation for adding a MTTCG thread we re-factor out a bit of what will be common code to handle the QEMU_CLOCK_VIRTUAL expiration. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - split from exit_request patch --- cpus.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cpus.c b/cpus.c index aca2a2e..6367772 100644 --- a/cpus.c +++ b/cpus.c @@ -1172,6 +1172,18 @@ static int64_t tcg_get_icount_limit(void) } } +static void handle_icount_deadline(void) +{ + if (use_icount) { + int64_t deadline = + qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + + if (deadline == 0) { + qemu_clock_notify(QEMU_CLOCK_VIRTUAL); + } + } +} + static int tcg_cpu_exec(CPUState *cpu) { int ret; @@ -1310,13 +1322,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) /* Pairs with smp_wmb in qemu_cpu_kick. */ atomic_mb_set(&exit_request, 0); - if (use_icount) { - int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + handle_icount_deadline(); - if (deadline == 0) { - qemu_clock_notify(QEMU_CLOCK_VIRTUAL); - } - } qemu_tcg_wait_io_event(QTAILQ_FIRST(&cpus)); deal_with_unplugged_cpus(); } -- 2.10.1