From patchwork Mon Oct 31 14:13:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 80191 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp152689qge; Mon, 31 Oct 2016 07:43:28 -0700 (PDT) X-Received: by 10.55.96.194 with SMTP id u185mr19576401qkb.140.1477925008087; Mon, 31 Oct 2016 07:43:28 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m190si17797807qkd.35.2016.10.31.07.43.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:43:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:36064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Do7-0002B5-F4 for patch@linaro.org; Mon, 31 Oct 2016 10:43:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1DLg-0000O8-Jy for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:14:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1DLf-0002zs-RM for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:14:04 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1DLf-0002ze-Jn for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:14:03 -0400 Received: by mail-wm0-x241.google.com with SMTP id c17so18623595wmc.3 for ; Mon, 31 Oct 2016 07:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0zsmjTGdqGhKys7bofTCjc8bMzX+fsggUaRDggVHWKE=; b=uELqv3oG19A+7Lg5Lh4R4fkZrFlWR3WPJNbThKPKwvLZInFLQ+NesK4r44Qb7N4B24 pwYX12ZXYBnIBOthODZuQa9fAlMAPY4UuNl5elARAS3k2Iw6VSO+ZV+IxRVdyKz0Wuam KfWJBTHZT1sw+ez5HuqCbtIaQ8lflo45Lu7ciO7QyC4At8eIqk+gS4TADvkIDMfOsdiD xtq+ENXtzu2zVwm/Pu3pz4GxLWXq3fnxWStDpAFBTj4xEQL7HuAlMwcSRJ2cwoOTrlSc cGWHPc6h3bS5vTlNFm5iSzbXp7LOeca+D6oGuCLK8wq7WYPySgsZw3lGHLipZD7dGAM9 C8sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0zsmjTGdqGhKys7bofTCjc8bMzX+fsggUaRDggVHWKE=; b=BXfJQ3+CjsWvSWl/Jc6D+jhiXdtsuNGnHeWxbF457y7Ea5Y9YMUYyxYl2CUQGKfIaK 7Q3W5zorRH5msvmheYdP3JxtxEBl1zatyCRbQuetjWDqVeCxVUguNeVU/EuttR+cVyMx xW3fwlFrCYONb0f2ERjLmL85dKWX2JFpGmMfl7Fou2uLX30QIamtL4EOmg5kVFmghYOd 3UpJvMmfYrlpRa2qboz2MxLCvZSa2amOq1jEXOF3arQAQmXqROBkEz9pi2bsN1rfhcXw b49xa6KWdINwrzr24zxLMxUgVJDc3+aLrXBJDXMjN71E/w9+oPNyDDMtl22gW0okXmDP NYMg== X-Gm-Message-State: ABUngveGLyWUQ5JIjlhLE8l0Z2pUf9QEBde0VMuKLOleA9P51jiX3QCf6sJyIdjL9WZkuA== X-Received: by 10.194.104.40 with SMTP id gb8mr22546224wjb.28.1477923242528; Mon, 31 Oct 2016 07:14:02 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-246-178.clienti.tiscali.it. [78.12.246.178]) by smtp.gmail.com with ESMTPSA id p13sm25052133wmd.20.2016.10.31.07.13.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 07:14:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 31 Oct 2016 15:13:33 +0100 Message-Id: <1477923215-30323-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477923215-30323-1-git-send-email-pbonzini@redhat.com> References: <1477923215-30323-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 12/14] cpus: re-factor out handle_icount_deadline X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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 Message-Id: <20161027151030.20863-18-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- cpus.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/cpus.c b/cpus.c index cc49902..6f0dc1a 100644 --- a/cpus.c +++ b/cpus.c @@ -1076,6 +1076,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; @@ -1198,13 +1210,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(); }