From patchwork Tue Apr 5 15:32:21 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: 8753021 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 02D44C0553 for ; Tue, 5 Apr 2016 15:34:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BDDC20396 for ; Tue, 5 Apr 2016 15:34:24 +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 2D2F52011D for ; Tue, 5 Apr 2016 15:34:23 +0000 (UTC) Received: from localhost ([::1]:37795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSzm-00014a-IX for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Apr 2016 11:34:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSyA-0006oe-AL for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:32:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anSy9-0007FF-05 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:32:42 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:37583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSy8-0007F7-N5 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:32:40 -0400 Received: by mail-wm0-x22b.google.com with SMTP id n3so26882681wmn.0 for ; Tue, 05 Apr 2016 08:32:40 -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=fbjT0JZxqyyRZSS5u4YVpxVJjFu5Lm/gvUQp/MF19p4=; b=fKMMzwn/SanCXTy2QuId/SxobVOJEirjsCG2TQpaPG8/TO0K0ShJ4EdEevlI1GYmRV MXXpXf5td219bd4Y9E3kJbIztAEfmqppACLPWVfTMgMqyW54KOuvBum/uo6kmTK6Z2gk G3IOWRyGi+x/AMwHju3bGdHVECcj6jAKcws4o= 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=fbjT0JZxqyyRZSS5u4YVpxVJjFu5Lm/gvUQp/MF19p4=; b=Z8oL+IC2f/fR93eW/XWnmcQwAnJbrNGPo4q2jW1N/aRJNKqZOgNacnnKONyxwu2RAu /lHVHqLV5yJJ6JQ9ihjOqQpfvu/B7e1ToOjlCFI5/muhr5KTjaCBRaBRsGT9WJVI0/qJ 2dk2LsvgQsEfdFFS6Hgn6hmx26tDIOrvwkLR9qTe2mrP5I8HiIq3L5Iy5FA22ZnQb2f9 T3Tr5zT8+gO1eC1BYXZQc/7cKpT4F9L1gGsCQHJr4/MKwc8KStFY361jWBmg3Mc5srDJ BVpQnpWG4u38dTRShd6IFNypjL1m4m9J+X3CX8+bV05R7N4brHixvp36vAe+hqbiQmio y4JQ== X-Gm-Message-State: AD7BkJI3+sk8WFzQVIQ+NHlzrzmhhnyIE8+A2w0+mcyogSI1TQmKucJGTPEjfC3AFGVbtKRh X-Received: by 10.194.227.1 with SMTP id rw1mr13124287wjc.62.1459870360036; 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 w202sm18855798wmw.18.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 7A6C13E06EB; 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:21 +0100 Message-Id: <1459870344-16773-9-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::22b 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?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= , rth@twiddle.net Subject: [Qemu-devel] [RFC v2 08/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 v2: - machine_init->opts_init --- 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 46732a5..8d27fb0 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" @@ -146,6 +147,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); +} + +opts_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 13eeaae..5e3826c 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -369,6 +369,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 a770086..4eca704 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3224,6 +3224,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 bd81ea9..51bbdbc 100644 --- a/vl.c +++ b/vl.c @@ -2961,7 +2961,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();