From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 3/6: 2/2] accel/tcg: Track current value of can_do_io in the TB
Date: Fri, 15 Sep 2023 11:41:09 +0200 [thread overview]
Message-ID: <20230915094109.82757-2-philmd@linaro.org> (raw)
In-Reply-To: <20230915094109.82757-1-philmd@linaro.org>
From: Richard Henderson <richard.henderson@linaro.org>
Simplify translator_io_start by recording the current
known value of can_do_io within DisasContextBase.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20230914174436.1597356-4-richard.henderson@linaro.org>
[PMD: Split patch in 2, extracting set_can_do_io() first]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/translator.h | 2 ++
accel/tcg/translator.c | 14 +++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/include/exec/translator.h b/include/exec/translator.h
index 4e17c4f401..9d9e980819 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -72,6 +72,7 @@ typedef enum DisasJumpType {
* @num_insns: Number of translated instructions (including current).
* @max_insns: Maximum number of instructions to be translated in this TB.
* @singlestep_enabled: "Hardware" single stepping enabled.
+ * @saved_can_do_io: Known value of cpu->neg.can_do_io, or -1 for unknown.
*
* Architecture-agnostic disassembly context.
*/
@@ -83,6 +84,7 @@ typedef struct DisasContextBase {
int num_insns;
int max_insns;
bool singlestep_enabled;
+ int8_t saved_can_do_io;
void *host_addr[2];
} DisasContextBase;
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index cebf0a84cc..850d82e26f 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -18,9 +18,12 @@
static void set_can_do_io(DisasContextBase *db, bool val)
{
- tcg_gen_st_i32(tcg_constant_i32(val), cpu_env,
- offsetof(ArchCPU, parent_obj.can_do_io) -
- offsetof(ArchCPU, env));
+ if (db->saved_can_do_io != val) {
+ db->saved_can_do_io = val;
+ tcg_gen_st_i32(tcg_constant_i32(val), cpu_env,
+ offsetof(ArchCPU, parent_obj.can_do_io) -
+ offsetof(ArchCPU, env));
+ }
}
bool translator_io_start(DisasContextBase *db)
@@ -30,10 +33,6 @@ bool translator_io_start(DisasContextBase *db)
if (!(cflags & CF_USE_ICOUNT)) {
return false;
}
- if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
- /* Already started in translator_loop. */
- return true;
- }
set_can_do_io(db, true);
@@ -144,6 +143,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
db->num_insns = 0;
db->max_insns = *max_insns;
db->singlestep_enabled = cflags & CF_SINGLE_STEP;
+ db->saved_can_do_io = -1;
db->host_addr[0] = host_pc;
db->host_addr[1] = NULL;
--
2.41.0
next prev parent reply other threads:[~2023-09-15 9:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 17:44 [PATCH 0/6] accel/tcg: Always require can_do_io (#1866) Richard Henderson
2023-09-14 17:44 ` [PATCH 1/6] accel/tcg: Avoid load of icount_decr if unused Richard Henderson
2023-09-15 9:23 ` Philippe Mathieu-Daudé
2023-09-14 17:44 ` [PATCH 2/6] accel/tcg: Hoist CF_MEMI_ONLY check outside translation loop Richard Henderson
2023-09-15 9:26 ` Philippe Mathieu-Daudé
2023-09-14 17:44 ` [PATCH 3/6] accel/tcg: Track current value of can_do_io in the TB Richard Henderson
2023-09-15 9:41 ` [PATCH 3/6: 1/2] accel/tcg: Refactor gen_io_start() as set_can_do_io() Philippe Mathieu-Daudé
2023-09-15 9:41 ` Philippe Mathieu-Daudé [this message]
2023-09-15 9:44 ` [PATCH 3/6: 2/2] accel/tcg: Track current value of can_do_io in the TB Philippe Mathieu-Daudé
2023-09-15 9:42 ` [PATCH 3/6: 1/2] accel/tcg: Refactor gen_io_start() as set_can_do_io() Philippe Mathieu-Daudé
2023-09-14 17:44 ` [PATCH 4/6] accel/tcg: Improve setting of can_do_io at start of TB Richard Henderson
2023-09-15 9:47 ` Philippe Mathieu-Daudé
2023-09-14 17:44 ` [PATCH 5/6] accel/tcg: Always set CF_LAST_IO with CF_NOIRQ Richard Henderson
2023-09-19 9:26 ` Philippe Mathieu-Daudé
2023-09-14 17:44 ` [PATCH 6/6] accel/tcg: Always require can_do_io Richard Henderson
2023-09-19 9:37 ` Philippe Mathieu-Daudé
2023-10-24 9:50 ` Clément Chigot
2023-10-26 0:44 ` Richard Henderson
2023-10-26 8:10 ` Clément Chigot
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=20230915094109.82757-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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).