All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: Matt Turner <mattst88@gmail.com>, qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, pbonzini@redhat.com,
	philmd@mailo.com, zhao1.liu@intel.com, laurent@vivier.eu,
	deller@gmx.de, pierrick.bouvier@oss.qualcomm.com
Subject: Re: [PATCH 3/8] accel/tcg: skip the can_do_io stores in user-only builds
Date: Wed, 19 Aug 2026 02:13:06 +0200	[thread overview]
Message-ID: <a21cf4e9-7e42-4118-94bf-778c03e16048@oss.qualcomm.com> (raw)
In-Reply-To: <20260818174247.649526-4-mattst88@gmail.com>

I presume this is v2 of
https://lore.kernel.org/qemu-devel/20260817190038.580257-1-mattst88@gmail.com/

On 18/8/26 19:42, Matt Turner wrote:
> Every translation block stores to cpu->neg.can_do_io twice: false before
> the first instruction, true before the last one. Nothing reads it in a
> user-only build. There is no memory-mapped I/O in linux-user, and every
> reader is in system_ss: cputlb.c, watchpoint.c, icount-common.c and
> tcg-accel-ops-icount.c.
> 
> Two stores per TB is not much on its own, but TBs are short. An emulated
> alpha gcc 16.2.0 compiling the SQLite 3.45.1 amalgamation (255k lines,
> -O2) executes 34.2 billion TBs at 6.04 guest instructions each, so this is
> 68 billion stores for nothing.
> 
> Measured on an x86-64 host, LTO build, on top of the preceding two
> patches:
> 
>      before: 1,469,729,281,442 instructions
>      after:  1,402,816,253,499 instructions   -4.55%
> 
>      before: 120.97s wall clock
>      after:  115.75s wall clock              -4.32%
> 
> The emulated compiler produces byte-identical output.
> 
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
>   accel/tcg/translator.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git ./accel/tcg/translator.c ./accel/tcg/translator.c
> index cd7d079fe0..85bb21e911 100644
> --- ./accel/tcg/translator.c
> +++ ./accel/tcg/translator.c
> @@ -23,6 +23,9 @@
>   
>   static void set_can_do_io(DisasContextBase *db, bool val)
>   {
> +    if (IS_ENABLED(CONFIG_USER_ONLY)) {

Excellent use of IS_ENABLED()!

> +        return;
> +    }
>       QEMU_BUILD_BUG_ON(sizeof_field(CPUState, neg.can_do_io) != 1);
>       tcg_gen_st8_i32(tcg_constant_i32(val), tcg_env,
>                       offsetof(CPUState, neg.can_do_io) - sizeof(CPUState));
> @@ -210,6 +213,10 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
>       /*
>        * Manage can_do_io for the translation block: set to false before
>        * the first insn and set to true before the last insn.
> +     *
> +     * Nothing reads can_do_io in user-only builds.  There is no MMIO
> +     * there, and every reader (cputlb.c, watchpoint.c, icount) is in
> +     * system_ss, so skip the two stores per TB entirely.
>        */
>       if (db->num_insns == 1) {
>           tcg_debug_assert(first_insn_start == db->insn_start);

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>



  parent reply	other threads:[~2026-08-19  0:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 17:42 [RFC PATCH 0/8] accel/tcg: cut per-block dispatch overhead Matt Turner
2026-08-18 17:42 ` [PATCH 1/8] accel/tcg: cache the result of curr_cflags() Matt Turner
2026-08-18 22:45   ` Richard Henderson
2026-08-19 11:32     ` BALATON Zoltan
2026-08-18 17:42 ` [PATCH 2/8] accel/tcg: enlarge the TB jump cache to 64K entries Matt Turner
2026-08-18 22:46   ` Richard Henderson
2026-08-18 17:42 ` [PATCH 3/8] accel/tcg: skip the can_do_io stores in user-only builds Matt Turner
2026-08-18 22:47   ` Richard Henderson
2026-08-19  0:13   ` Philippe Mathieu-Daudé [this message]
2026-08-18 17:42 ` [PATCH 4/8] RFC: tcg: probe the TB jump cache inline instead of calling a helper Matt Turner
2026-08-18 21:51   ` Pierrick Bouvier
2026-08-19  0:10     ` Matt Turner
2026-08-18 22:26   ` Mohamed Mediouni
2026-08-19  1:03     ` Matt Turner
2026-08-19  0:34   ` Philippe Mathieu-Daudé
2026-08-18 17:42 ` [PATCH 5/8] RFC: accel/tcg: allow cross-page goto_tb chaining in user-only builds Matt Turner
2026-08-18 17:42 ` [PATCH 6/8] RFC: accel/tcg: only poll for interrupts in blocks that can close a cycle Matt Turner
2026-08-18 23:36   ` Richard Henderson
2026-08-18 17:42 ` [PATCH 7/8] RFC: accel/tcg: poison the jump cache instead of polling for indirect exits Matt Turner
2026-08-18 17:42 ` [PATCH 8/8] RFC: tcg: fold a guest displacement into the host addressing mode Matt Turner
2026-08-18 22:52 ` [RFC PATCH 0/8] accel/tcg: cut per-block dispatch overhead Richard Henderson

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=a21cf4e9-7e42-4118-94bf-778c03e16048@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=deller@gmx.de \
    --cc=laurent@vivier.eu \
    --cc=mattst88@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@mailo.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhao1.liu@intel.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.