From patchwork Tue Apr 5 15:32:20 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: 8753111 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 44EAF9F3D1 for ; Tue, 5 Apr 2016 15:36:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D1852038E for ; Tue, 5 Apr 2016 15:36:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D67C42011D for ; Tue, 5 Apr 2016 15:36:30 +0000 (UTC) Received: from localhost ([::1]:37821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anT1q-0004d5-6K for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Apr 2016 11:36:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSyD-0006v7-RQ for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:32:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anSy9-0007FV-PQ for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:32:45 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:34458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSy9-0007FP-FA for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:32:41 -0400 Received: by mail-wm0-x229.google.com with SMTP id l6so28824895wml.1 for ; Tue, 05 Apr 2016 08:32:41 -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=Ny02XagXUfz8yDbO6pYD4oYEYsW0yrjfTvlR8QB2atE=; b=aksElO4wm4VrpmhPMdSola/hRcygtWG+/7Yjgwjg8ygcNPV0dAdtkVf9A6a1L9iRoq bdZDMLKl6kjuD6ufcTG0orLgtocju4H5jW63ceKf2xuw9ZH/g7ipqE3ARCzDeSkqH3MC 8x49u7NdGjx+tBxga9HX9TwomBZjU5PGY52/0= 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=Ny02XagXUfz8yDbO6pYD4oYEYsW0yrjfTvlR8QB2atE=; b=bdikLiYcKdEsVDBnkhnQUYwXeQq2M71CqHMGEgj80U3fi0FPHuU0urvv0CgOAmHv2R yZV05PqjfcM6dr++nlEaBvPEiAybR+whs4M/2bSdDjFuwqZ5v/vjczGHaF4H+Noyhp/g 0yh+MAOheuMcYh8AHUetGD/PMUN7sSsgOy7ZcbDhzEB8y62XJaSE4KBl2sUL/9gAT5yq JESPn/tOESQhuEJNdSQk7WdrWypD0X3TCdlv6eU4FRiHwLodfKP0y8BK9KVDYjP/QFWB 3d+dFqieK+LnwdycIftnLZFOmpViuUDAtkRIjC9yD3/E4iBCMrUbDN+7EaEFD2lFNkUX 9XKQ== X-Gm-Message-State: AD7BkJKSqMlPIHD/rQ50no7xKiT9EK4CE/Avvbwe5A5z3dxDg+72XziGlNjWCSbRaDNUlmO8 X-Received: by 10.28.132.212 with SMTP id g203mr18736199wmd.30.1459870360894; Tue, 05 Apr 2016 08:32:40 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t3sm35260514wjz.11.2016.04.05.08.32.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2016 08:32:36 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6512A3E05B2; Tue, 5 Apr 2016 16:32:33 +0100 (BST) 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: Tue, 5 Apr 2016 16:32:20 +0100 Message-Id: <1459870344-16773-8-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1459870344-16773-1-git-send-email-alex.bennee@linaro.org> References: <1459870344-16773-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::229 Cc: peter.maydell@linaro.org, claudio.fontana@huawei.com, Peter Crosthwaite , jan.kiszka@siemens.com, mark.burton@greensocs.com, qemu-devel@nongnu.org, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , rth@twiddle.net Subject: [Qemu-devel] [RFC v2 07/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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v2 - update timer calls to new API on rebase --- cpus.c | 63 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/cpus.c b/cpus.c index e118fdf..46732a5 100644 --- a/cpus.c +++ b/cpus.c @@ -67,7 +67,6 @@ #endif /* CONFIG_LINUX */ -static CPUState *next_cpu; int64_t max_delay; int64_t max_advance; @@ -1109,7 +1108,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) { @@ -1140,8 +1139,35 @@ 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(); + + 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); @@ -1500,37 +1526,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_account_warp_timer(); - - 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 */