All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: thuth@redhat.com, armbru@redhat.com
Subject: [PATCH 12/16] tcg: add "-accel tcg,tb-size" and deprecate "-tb-size"
Date: Wed, 13 Nov 2019 15:39:01 +0100	[thread overview]
Message-ID: <1573655945-14912-13-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com>

-tb-size fits nicely in the new framework for accelerator-specific options.  It
is a very niche option, so insta-deprecate the old version.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/tcg/tcg-all.c    | 40 +++++++++++++++++++++++++++++++++++++---
 include/sysemu/accel.h |  2 --
 qemu-deprecated.texi   |  6 ++++++
 qemu-options.hx        |  6 +++++-
 vl.c                   |  8 ++++----
 5 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 7829f02..1dc384c 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -34,11 +34,13 @@
 #include "include/qapi/error.h"
 #include "include/qemu/error-report.h"
 #include "include/hw/boards.h"
+#include "qapi/qapi-builtin-visit.h"
 
 typedef struct TCGState {
     AccelState parent_obj;
 
     bool mttcg_enabled;
+    unsigned long tb_size;
 } TCGState;
 
 #define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
@@ -46,8 +48,6 @@ typedef struct TCGState {
 #define TCG_STATE(obj) \
         OBJECT_CHECK(TCGState, (obj), TYPE_TCG_ACCEL)
 
-unsigned long tcg_tb_size;
-
 /* mask must never be zero, except for A20 change call */
 static void tcg_handle_interrupt(CPUState *cpu, int mask)
 {
@@ -126,7 +126,7 @@ static int tcg_init(MachineState *ms)
 {
     TCGState *s = TCG_STATE(current_machine->accelerator);
 
-    tcg_exec_init(tcg_tb_size * 1024 * 1024);
+    tcg_exec_init(s->tb_size * 1024 * 1024);
     cpu_interrupt_handler = tcg_handle_interrupt;
     mttcg_enabled = s->mttcg_enabled;
     return 0;
@@ -167,6 +167,33 @@ static void tcg_set_thread(Object *obj, const char *value, Error **errp)
     }
 }
 
+static void tcg_get_tb_size(Object *obj, Visitor *v,
+                            const char *name, void *opaque,
+                            Error **errp)
+{
+    TCGState *s = TCG_STATE(obj);
+    uint32_t value = s->tb_size;
+
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void tcg_set_tb_size(Object *obj, Visitor *v,
+                            const char *name, void *opaque,
+                            Error **errp)
+{
+    TCGState *s = TCG_STATE(obj);
+    Error *error = NULL;
+    uint32_t value;
+
+    visit_type_uint32(v, name, &value, &error);
+    if (error) {
+        error_propagate(errp, error);
+        return;
+    }
+
+    s->tb_size = value;
+}
+
 static void tcg_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
@@ -178,6 +205,13 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
                                   tcg_get_thread,
                                   tcg_set_thread,
                                   NULL);
+
+    object_class_property_add(oc, "tb-size", "int",
+        tcg_get_tb_size, tcg_set_tb_size,
+        NULL, NULL, &error_abort);
+    object_class_property_set_description(oc, "tb-size",
+        "TCG translation block cache size", &error_abort);
+
 }
 
 static const TypeInfo tcg_accel_type = {
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 22cac0f..d4c1429 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -64,8 +64,6 @@ typedef struct AccelClass {
 #define ACCEL_GET_CLASS(obj) \
     OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
 
-extern unsigned long tcg_tb_size;
-
 AccelClass *accel_find(const char *opt_name);
 int accel_init_machine(AccelState *accel, MachineState *ms);
 
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 7239e09..6ca5f80 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -147,6 +147,12 @@ QEMU 4.1 has three options, please migrate to one of these three:
       to do is specify the kernel they want to boot with the -kernel option
  3. ``-bios <file>`` - Tells QEMU to load the specified file as the firmwrae.
 
+@subsection -tb-size option (since 5.0)
+
+QEMU 5.0 introduced an alternative syntax to specify the size of the translation
+block cache, @option{-accel tcg,tb-size=}.  The new syntax deprecates the
+previously available @option{-tb-size} option.
+
 @section QEMU Machine Protocol (QMP) commands
 
 @subsection query-block result field dirty-bitmaps[i].status (since 4.0)
diff --git a/qemu-options.hx b/qemu-options.hx
index b95bf9f..3931f90 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -120,6 +120,7 @@ ETEXI
 DEF("accel", HAS_ARG, QEMU_OPTION_accel,
     "-accel [accel=]accelerator[,thread=single|multi]\n"
     "                select accelerator (kvm, xen, hax, hvf, whpx or tcg; use 'help' for a list)\n"
+    "                tb-size=n (TCG translation block cache size)\n"
     "                thread=single|multi (enable multi-threaded TCG)\n", QEMU_ARCH_ALL)
 STEXI
 @item -accel @var{name}[,prop=@var{value}[,...]]
@@ -129,6 +130,8 @@ kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If th
 more than one accelerator specified, the next one is used if the previous one
 fails to initialize.
 @table @option
+@item tb-size=@var{n}
+Controls the size (in MiB) of the TCG translation block cache.
 @item thread=single|multi
 Controls number of TCG threads. When the TCG is multi-threaded there will be one
 thread per vCPU therefor taking advantage of additional host cores. The default
@@ -3995,7 +3998,8 @@ DEF("tb-size", HAS_ARG, QEMU_OPTION_tb_size, \
 STEXI
 @item -tb-size @var{n}
 @findex -tb-size
-Set TB size.
+Set TCG translation block cache size.  Deprecated, use @samp{-accel tcg,tb-size=@var{n}}
+instead.
 ETEXI
 
 DEF("incoming", HAS_ARG, QEMU_OPTION_incoming, \
diff --git a/vl.c b/vl.c
index 2ea94c7..06c6ad9 100644
--- a/vl.c
+++ b/vl.c
@@ -2857,6 +2857,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
         return 0;
     }
     accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+    object_apply_compat_props(OBJECT(accel));
     qemu_opt_foreach(opts, accelerator_set_property,
                      accel,
                      &error_fatal);
@@ -2868,6 +2869,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
                      acc, strerror(-ret));
         return 0;
     }
+
     return 1;
 }
 
@@ -3747,10 +3749,8 @@ int main(int argc, char **argv, char **envp)
                 error_report("TCG is disabled");
                 exit(1);
 #endif
-                if (qemu_strtoul(optarg, NULL, 0, &tcg_tb_size) < 0) {
-                    error_report("Invalid argument to -tb-size");
-                    exit(1);
-                }
+                warn_report("The -tb-size option is deprecated, use -accel tcg,tb-size instead");
+                object_register_sugar_prop(ACCEL_CLASS_NAME("tcg"), "tb-size", optarg);
                 break;
             case QEMU_OPTION_icount:
                 icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"),
-- 
1.8.3.1




  parent reply	other threads:[~2019-11-13 14:52 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 14:38 [PATCH for-5.0 00/16] Complete the implementation of -accel Paolo Bonzini
2019-11-13 14:38 ` [PATCH 01/16] memory: do not look at current_machine->accel Paolo Bonzini
2019-11-14  8:56   ` Marc-André Lureau
2019-11-14  9:27     ` Paolo Bonzini
2019-11-14  9:31       ` Marc-André Lureau
2019-11-14  9:10   ` Thomas Huth
2019-11-14  9:35     ` Paolo Bonzini
2019-11-14  9:46       ` Thomas Huth
2019-11-14 10:21       ` Peter Maydell
2019-11-14 10:32         ` Paolo Bonzini
2019-11-14 10:40           ` Peter Maydell
2019-11-14 10:47             ` Paolo Bonzini
2019-11-13 14:38 ` [PATCH 02/16] vl: extract accelerator option processing to a separate function Paolo Bonzini
2019-11-14  7:55   ` Marc-André Lureau
2019-11-14  9:29     ` Paolo Bonzini
2019-11-18 10:58   ` Thomas Huth
2019-11-18 11:39     ` Paolo Bonzini
2019-11-13 14:38 ` [PATCH 03/16] vl: merge -accel processing into configure_accelerators Paolo Bonzini
2019-11-14  8:13   ` Marc-André Lureau
2019-11-18 11:27   ` Thomas Huth
2019-11-18 11:39     ` Paolo Bonzini
2019-11-18 15:12   ` Wainer dos Santos Moschetta
2019-11-13 14:38 ` [PATCH 04/16] vl: move icount configuration earlier Paolo Bonzini
2019-11-14  8:24   ` Marc-André Lureau
2019-11-18 11:53   ` Thomas Huth
2019-11-13 14:38 ` [PATCH 05/16] vl: introduce object_parse_property_opt Paolo Bonzini
2019-11-14  8:23   ` Marc-André Lureau
2019-11-14  9:46     ` Paolo Bonzini
2019-11-13 14:38 ` [PATCH 06/16] vl: configure accelerators from -accel options Paolo Bonzini
2019-11-18 17:59   ` Wainer dos Santos Moschetta
2019-11-13 14:38 ` [PATCH 07/16] vl: warn for unavailable accelerators, clarify messages Paolo Bonzini
2019-11-14  9:28   ` Marc-André Lureau
2019-11-13 14:38 ` [PATCH 08/16] qom: introduce object_register_sugar_prop Paolo Bonzini
2019-11-14  9:53   ` Marc-André Lureau
2019-11-14 10:03     ` Paolo Bonzini
2019-11-13 14:38 ` [PATCH 09/16] qom: add object_new_with_class Paolo Bonzini
2019-11-14  9:56   ` Marc-André Lureau
2019-11-13 14:38 ` [PATCH 10/16] accel: pass object to accel_init_machine Paolo Bonzini
2019-11-14 10:48   ` Marc-André Lureau
2019-11-13 14:39 ` [PATCH 11/16] tcg: convert "-accel threads" to a QOM property Paolo Bonzini
2019-11-14 11:08   ` Marc-André Lureau
2019-11-13 14:39 ` Paolo Bonzini [this message]
2019-11-19 10:44   ` [PATCH 12/16] tcg: add "-accel tcg,tb-size" and deprecate "-tb-size" Thomas Huth
2019-11-13 14:39 ` [PATCH 13/16] xen: convert "-machine igd-passthru" to an accelerator property Paolo Bonzini
2019-11-14  9:39   ` Paul Durrant
2019-11-14  9:39     ` [Xen-devel] " Paul Durrant
2019-11-14  9:47     ` Paolo Bonzini
2019-11-14  9:47       ` [Xen-devel] " Paolo Bonzini
2019-11-14  9:52       ` Paul Durrant
2019-11-14  9:52         ` [Xen-devel] " Paul Durrant
2019-11-19 11:02   ` Thomas Huth
2019-11-13 14:39 ` [PATCH 14/16] kvm: convert "-machine kvm_shadow_mem" " Paolo Bonzini
2019-11-19 11:33   ` Thomas Huth
2019-11-13 14:39 ` [PATCH 15/16] kvm: introduce kvm_kernel_irqchip_* functions Paolo Bonzini
2019-11-19 11:56   ` Thomas Huth
2019-11-19 12:13     ` Paolo Bonzini
2019-11-19 12:22       ` Thomas Huth
2019-11-13 14:39 ` [PATCH 16/16] kvm: convert "-machine kernel_irqchip" to an accelerator property Paolo Bonzini

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=1573655945-14912-13-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.