From patchwork Fri Mar 18 16:18:48 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: 8621761 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 57AEA9F6E1 for ; Fri, 18 Mar 2016 16:24:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71A382037F for ; Fri, 18 Mar 2016 16:24:04 +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 6388B2026F for ; Fri, 18 Mar 2016 16:24:03 +0000 (UTC) Received: from localhost ([::1]:44832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agxBy-0001Oy-De for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Mar 2016 12:24:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx7C-0000Sn-7A for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agx7A-0002xp-RM for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:06 -0400 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:38563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agx7A-0002xY-HT for qemu-devel@nongnu.org; Fri, 18 Mar 2016 12:19:04 -0400 Received: by mail-wm0-x22a.google.com with SMTP id l68so44374036wml.1 for ; Fri, 18 Mar 2016 09:19:04 -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=oV2KuU7MNrx2yi9DpM1l+1ZR/9UDafnhpExinOqfZGE=; b=HqyeFe8UT4HUAwk+RfT7Y/yBzBEI6lZRvNzmDlrRfU+l9kfjq4oZulbq3lz9Cf3ZWy mwLf4HaM1uSip1hJ7+y4Xw0321T6CVipgRAuyG3QpY+wqMpXxGjUw9bKnL5FXqf9mcNK PPajAn9eLG8CTln0ZnTWfGg8LBNqO1yvBpmFc= 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=oV2KuU7MNrx2yi9DpM1l+1ZR/9UDafnhpExinOqfZGE=; b=Gu0uSDGkifMNaHPfyDBM3bd39fquaO7M44uqGnCIj7gO1XbEuNIlZiS7OgQYSNRyMU L3d4ucT0OwWLi3KIbDKa8mjM1ZnkWhvtEBu9RkI7EAk9H/OWUBZGwHmt+iFt6D2scbbV XK2uj/kOOqcct7iEpHZ7q5Qe+6K+OWiUu1y84fP42SB/pvwpP6L8DpOlprM6LGsqIJVj N6sZ3JSdVHbKBfoO9vER84rjlboXxUJMbEhB6OfDtH+NzpYx6ce1wQMpExLGNP0kgUVw 88OgnkYlEr5JbBd32aVnCT/DDHC4xHXq3N0noDmFXdhxWxx8muPG0gyKsLx7Z/HWk9k1 IwSw== X-Gm-Message-State: AD7BkJK9Rt6RRLPUOixrUZTMmuWS0N29xxXRsoYKsrzEjMbpLXJR4p+nKnSpZGHkdHpG8WEV X-Received: by 10.28.3.138 with SMTP id 132mr254642wmd.20.1458317944034; Fri, 18 Mar 2016 09:19:04 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id ll9sm12853944wjc.29.2016.03.18.09.18.58 (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 391CC3E052F; 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:48 +0000 Message-Id: <1458317932-1875-8-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::22a Cc: Peter Crosthwaite , mark.burton@greensocs.com, qemu-devel@nongnu.org, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson Subject: [Qemu-devel] [RFC v1 07/11] tcg: add options for enabling MTTCG 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 From: KONRAD Frederic We know there will be cases where MTTCG won't work until additional work is done in the front/back ends to support. It will however be useful to be able to turn it on. As a result MTTCG will default to off unless the combination is supported. However the user can turn it on for the sake of testing. Signed-off-by: KONRAD Frederic [AJB: move to -tcg mttcg=on/off, defaults] Signed-off-by: Alex Bennée --- v1: - merge with add mttcg option. - update commit message --- cpus.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/qom/cpu.h | 14 ++++++++++++++ include/sysemu/cpus.h | 2 ++ qemu-options.hx | 14 ++++++++++++++ vl.c | 12 +++++++++++- 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 970d3ae..76bd321 100644 --- a/cpus.c +++ b/cpus.c @@ -25,6 +25,7 @@ /* Needed early for CONFIG_BSD etc. */ #include "qemu/osdep.h" +#include "qemu/config-file.h" #include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" @@ -145,6 +146,48 @@ typedef struct TimersState { } TimersState; static TimersState timers_state; +static bool mttcg_enabled; + +static QemuOptsList qemu_tcg_opts = { + .name = "tcg", + .head = QTAILQ_HEAD_INITIALIZER(qemu_tcg_opts.head), + .desc = { + { + .name = "mttcg", + .type = QEMU_OPT_BOOL, + .help = "Enable/disable multi-threaded TCG", + }, + { /* end of list */ } + }, +}; + +static void tcg_register_config(void) +{ + qemu_add_opts(&qemu_tcg_opts); +} + +machine_init(tcg_register_config); + +static bool default_mttcg_enabled(void) +{ + /* + * TODO: Check if we have a chance to have MTTCG working on this guest/host. + * Basically is the atomic instruction implemented? Is there any + * memory ordering issue? + */ + return false; +} + +void qemu_tcg_configure(QemuOpts *opts) +{ + mttcg_enabled = qemu_opt_get_bool(opts, "mttcg", default_mttcg_enabled()); +} + +bool qemu_tcg_mttcg_enabled(void) +{ + return mttcg_enabled; +} + int64_t cpu_get_icount_raw(void) { diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9124b6d..d6cb7b8 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -373,6 +373,20 @@ extern struct CPUTailQ cpus; extern __thread CPUState *current_cpu; /** + * qemu_tcg_enable_mttcg: + * Enable the MultiThread TCG support. + */ +void qemu_tcg_enable_mttcg(void); + +/** + * qemu_tcg_mttcg_enabled: + * Check whether we are running MultiThread TCG or not. + * + * Returns: %true if we are in MTTCG mode %false otherwise. + */ +bool qemu_tcg_mttcg_enabled(void); + +/** * cpu_paging_enabled: * @cpu: The CPU whose state is to be inspected. * diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index 3d1e5ba..606426f 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -26,4 +26,6 @@ extern int smp_threads; void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg); +void qemu_tcg_configure(QemuOpts *opts); + #endif diff --git a/qemu-options.hx b/qemu-options.hx index 0cf7bb9..52ab1f3 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3199,6 +3199,20 @@ Attach to existing xen domain. xend will use this when starting QEMU (XEN only). ETEXI +DEF("tcg", HAS_ARG, QEMU_OPTION_tcg, \ + "-tcg [mttcg=on|off] control TCG options\n", QEMU_ARCH_ALL) +STEXI +@item -tcg +@findex -tcg +@table @option +@item mttcg=[on|off] +Control multi-threaded TCG. By default QEMU will enable multi-threaded +emulation for front/back-end combinations that are known to work. The +user may enable it against the defaults however odd guest behaviour +may occur. +@end table +ETEXI + DEF("no-reboot", 0, QEMU_OPTION_no_reboot, \ "-no-reboot exit instead of rebooting\n", QEMU_ARCH_ALL) STEXI diff --git a/vl.c b/vl.c index 7a28982..1165506 100644 --- a/vl.c +++ b/vl.c @@ -2958,7 +2958,8 @@ int main(int argc, char **argv, char **envp) const char *boot_once = NULL; DisplayState *ds; int cyls, heads, secs, translation; - QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL; + QemuOpts *opts, *machine_opts; + QemuOpts *hda_opts = NULL, *icount_opts = NULL, *tcg_opts = NULL; QemuOptsList *olist; int optind; const char *optarg; @@ -3750,6 +3751,13 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_no_reboot: no_reboot = 1; break; + case QEMU_OPTION_tcg: + tcg_opts = qemu_opts_parse_noisily(qemu_find_opts("tcg"), + optarg, false); + if (!tcg_opts) { + exit(1); + } + break; case QEMU_OPTION_no_shutdown: no_shutdown = 1; break; @@ -4028,6 +4036,8 @@ int main(int argc, char **argv, char **envp) */ loc_set_none(); + qemu_tcg_configure(tcg_opts); + replay_configure(icount_opts); machine_class = select_machine();