From patchwork Fri Mar 18 16:18:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 64079 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp54327lbc; Fri, 18 Mar 2016 09:23:25 -0700 (PDT) X-Received: by 10.55.212.207 with SMTP id s76mr23254072qks.78.1458318204214; Fri, 18 Mar 2016 09:23:24 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t65si12791969qhc.2.2016.03.18.09.23.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Mar 2016 09:23:24 -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; 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; dkim=fail header.i=@linaro.org Received: from localhost ([::1]:44824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agxBL-0008PC-MU for patch@linaro.org; Fri, 18 Mar 2016 12:23:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx7A-0000RI-G3 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agx79-0002wp-A4 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:04 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:34230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx78-0002wg-W7 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:03 -0400 Received: by mail-wm0-x234.google.com with SMTP id p65so75846192wmp.1 for ; Fri, 18 Mar 2016 09:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+XsDJZSQ3CPIPOgkUEKxI4MN2FTwzswJoLfWd50ls10=; b=BqRK14aIg18o+lbKJ/mQrrFpiAxDJ3iCDAjv7iCErb9Q/dvVp+Edg3KLS0g9J/otAD DiNE6mhDBeR3dv3j7Th+ORpCoc8OjJGebEPGbxEYTT+QWz5X/m6kKZ6rO3eAxUqdop6s ohgtvN9jEshwV4NRwxEtgo2WL3NfQRHUm6fHk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+XsDJZSQ3CPIPOgkUEKxI4MN2FTwzswJoLfWd50ls10=; b=Ht7swxB/2L/l5XOtYHL6aR8Jf/O+lIRJmr4J0OYAazCH57Tkr/LxyLDIuroG6FxTuu KGjgIYO2IBywoB+PTMlLIo3Lj/eWjL7I7bI1DTt2BRW3H3b+mb7bY7rjcLV+k2TSd6uD kg1yLFTYZ2c1FM1mAj+lIBr8zQLuDHVXjnLzmWFJ5yE+vGvL99WjcgufxZ5V76H8g3EK qDO+kYTHaR8HzzLSaxVElvw9PJyFSDf9R+JiP7+CBqvBJ6kmGUf0bAf2I2pyUxB7d0Ty Zpm+3pnEEp5Q2rKuNdVStDRQbB+srdsRYYmKohv51jqx74A+wMxIAM1Xk8gVl1EQO+Ps JI6Q== X-Gm-Message-State: AD7BkJK1O6t1vkZf4BgLJ+UTUzFo0iTgui0jPDACa4sA1CZ0QjcVXNS2PMyrDZT0k0tq6d7x X-Received: by 10.28.171.8 with SMTP id u8mr184056wme.97.1458317942343; Fri, 18 Mar 2016 09:19:02 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j18sm20565wmd.2.2016.03.18.09.18.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 09:19:00 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2440C3E0529; Fri, 18 Mar 2016 16:18:56 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, serge.fdrv@gmail.com, cota@braap.org Date: Fri, 18 Mar 2016 16:18:47 +0000 Message-Id: <1458317932-1875-7-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458317932-1875-1-git-send-email-alex.bennee@linaro.org> References: <1458317932-1875-1-git-send-email-alex.bennee@linaro.org> 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::234 Cc: Peter Crosthwaite , mark.burton@greensocs.com, qemu-devel@nongnu.org, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [Qemu-devel] [RFC v1 06/11] tcg: cpus rm tcg_exec_all() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In preparation for multi-threaded TCG we remove tcg_exec_all and move all the CPU cycling into the main thread function. When MTTCG is enabled we shall use a separate thread function which only handles one vCPU. Signed-off-by: Alex Bennée --- cpus.c | 64 ++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) -- 2.7.3 diff --git a/cpus.c b/cpus.c index bc774e2..970d3ae 100644 --- a/cpus.c +++ b/cpus.c @@ -66,7 +66,6 @@ #endif /* CONFIG_LINUX */ -static CPUState *next_cpu; int64_t max_delay; int64_t max_advance; @@ -1103,7 +1102,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) #endif } -static void tcg_exec_all(void); +static int tcg_cpu_exec(CPUState *cpu); static void *qemu_tcg_cpu_thread_fn(void *arg) { @@ -1134,8 +1133,36 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) /* process any pending work */ atomic_mb_set(&exit_request, 1); + cpu = first_cpu; + while (1) { - tcg_exec_all(); + /* Account partial waits to QEMU_CLOCK_VIRTUAL. */ + /* qemu_account_warp_timer(); */ + qemu_clock_warp(QEMU_CLOCK_VIRTUAL); + + if (!cpu) { + cpu = first_cpu; + } + + for (; cpu != NULL && !exit_request; cpu = CPU_NEXT(cpu)) { + + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, + (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0); + + if (cpu_can_run(cpu)) { + int r = tcg_cpu_exec(cpu); + if (r == EXCP_DEBUG) { + cpu_handle_guest_debug(cpu); + break; + } + } else if (cpu->stop || cpu->stopped) { + break; + } + + } /* for cpu.. */ + + /* 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); @@ -1494,37 +1521,6 @@ static int tcg_cpu_exec(CPUState *cpu) return ret; } -static void tcg_exec_all(void) -{ - int r; - - /* Account partial waits to QEMU_CLOCK_VIRTUAL. */ - qemu_clock_warp(QEMU_CLOCK_VIRTUAL); - - if (next_cpu == NULL) { - next_cpu = first_cpu; - } - for (; next_cpu != NULL && !exit_request; next_cpu = CPU_NEXT(next_cpu)) { - CPUState *cpu = next_cpu; - - qemu_clock_enable(QEMU_CLOCK_VIRTUAL, - (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0); - - if (cpu_can_run(cpu)) { - r = tcg_cpu_exec(cpu); - if (r == EXCP_DEBUG) { - cpu_handle_guest_debug(cpu); - break; - } - } else if (cpu->stop || cpu->stopped) { - break; - } - } - - /* Pairs with smp_wmb in qemu_cpu_kick. */ - atomic_mb_set(&exit_request, 0); -} - void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg) { /* XXX: implement xxx_cpu_list for targets that still miss it */