From: "Alex Bennée" <alex.bennee@linaro.org>
To: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com,
a.rigo@virtualopensystems.com, serge.fdrv@gmail.com,
cota@braap.org
Cc: "Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
mark.burton@greensocs.com, qemu-devel@nongnu.org,
pbonzini@redhat.com, "Alex Bennée" <alex.bennee@linaro.org>,
"Andreas Färber" <afaerber@suse.de>,
"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [RFC v1 07/11] tcg: add options for enabling MTTCG
Date: Fri, 18 Mar 2016 16:18:48 +0000 [thread overview]
Message-ID: <1458317932-1875-8-git-send-email-alex.bennee@linaro.org> (raw)
In-Reply-To: <1458317932-1875-1-git-send-email-alex.bennee@linaro.org>
From: KONRAD Frederic <fred.konrad@greensocs.com>
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 <fred.konrad@greensocs.com>
[AJB: move to -tcg mttcg=on/off, defaults]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
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();
--
2.7.3
next prev parent reply other threads:[~2016-03-18 16:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-18 16:18 [Qemu-devel] [RFC v1 00/11] Base enabling patches for MTTCG Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 01/11] tcg: move tb_find_fast outside the tb_lock critical section Alex Bennée
2016-03-18 16:54 ` Paolo Bonzini
2016-03-21 21:50 ` Emilio G. Cota
2016-03-21 22:08 ` Peter Maydell
2016-03-21 23:59 ` Emilio G. Cota
2016-03-22 8:29 ` Paolo Bonzini
2016-03-22 11:59 ` Alex Bennée
2016-03-22 11:55 ` Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 02/11] cpu-exec: elide more icount code if CONFIG_USER_ONLY Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 03/11] tcg: comment on which functions have to be called with tb_lock held Alex Bennée
2016-03-18 16:59 ` Paolo Bonzini
2016-03-21 21:50 ` Emilio G. Cota
2016-03-21 22:12 ` Paolo Bonzini
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 04/11] tcg: protect TBContext with tb_lock Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 05/11] target-arm/psci.c: wake up sleeping CPUs Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 06/11] tcg: cpus rm tcg_exec_all() Alex Bennée
2016-03-18 16:18 ` Alex Bennée [this message]
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 08/11] tcg: add kick timer for single-threaded vCPU emulation Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 09/11] tcg: drop global lock during TCG code execution Alex Bennée
2016-03-18 16:49 ` Paolo Bonzini
2016-03-23 9:19 ` KONRAD Frederic
2016-03-23 16:27 ` Alex Bennée
2016-03-23 20:36 ` Jan Kiszka
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 10/11] tcg: grab iothread lock in cpu-exec interrupt handling Alex Bennée
2016-03-18 16:48 ` Paolo Bonzini
2016-03-22 12:03 ` Alex Bennée
2016-03-18 16:18 ` [Qemu-devel] [RFC v1 11/11] tcg: enable thread-per-vCPU Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458317932-1875-8-git-send-email-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=a.rigo@virtualopensystems.com \
--cc=afaerber@suse.de \
--cc=cota@braap.org \
--cc=crosthwaite.peter@gmail.com \
--cc=fred.konrad@greensocs.com \
--cc=mark.burton@greensocs.com \
--cc=mttcg@listserver.greensocs.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=serge.fdrv@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).