From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
robhenry@microsoft.com, aaron@os.amperecomputing.com,
cota@braap.org, "Paolo Bonzini" <pbonzini@redhat.com>,
kuhn.chenqun@huawei.com, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [PATCH v1 08/12] accel/tcg: cache single instruction TB on pending replay exception
Date: Tue, 9 Feb 2021 18:27:44 +0000 [thread overview]
Message-ID: <20210209182749.31323-9-alex.bennee@linaro.org> (raw)
In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org>
Again there is no reason to jump through the nocache hoops to execute
a single instruction block. We do have to add an additional wrinkle to
the cpu_handle_interrupt case to ensure we let through a TB where we
have specifically disabled icount for the block.
As the last user of cpu_exec_nocache we can now remove the function.
Further clean-up will follow in subsequent patches.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
accel/tcg/cpu-exec.c | 44 ++++----------------------------------------
1 file changed, 4 insertions(+), 40 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 7f477af891..609a68a3ae 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -224,40 +224,6 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
return last_tb;
}
-#ifndef CONFIG_USER_ONLY
-/* Execute the code without caching the generated code. An interpreter
- could be used if available. */
-static void cpu_exec_nocache(CPUState *cpu, int max_cycles,
- TranslationBlock *orig_tb, bool ignore_icount)
-{
- TranslationBlock *tb;
- uint32_t cflags = curr_cflags() | CF_NOCACHE;
- int tb_exit;
-
- if (ignore_icount) {
- cflags &= ~CF_USE_ICOUNT;
- }
-
- /* Should never happen.
- We only end up here when an existing TB is too long. */
- cflags |= MIN(max_cycles, CF_COUNT_MASK);
-
- mmap_lock();
- tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base,
- orig_tb->flags, cflags);
- tb->orig_tb = orig_tb;
- mmap_unlock();
-
- /* execute the generated code */
- trace_exec_tb_nocache(tb, tb->pc);
- cpu_tb_exec(cpu, tb, &tb_exit);
-
- mmap_lock();
- tb_phys_invalidate(tb, -1);
- mmap_unlock();
- tcg_tb_remove(tb);
-}
-#endif
static void cpu_exec_enter(CPUState *cpu)
{
@@ -524,15 +490,12 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
#ifndef CONFIG_USER_ONLY
if (replay_has_exception()
&& cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) {
- /* try to cause an exception pending in the log */
- cpu_exec_nocache(cpu, 1, tb_find(cpu, NULL, 0, curr_cflags()), true);
+ /* Execute just one insn to trigger exception pending in the log */
+ cpu->cflags_next_tb = (curr_cflags() & ~CF_USE_ICOUNT) | 1;
}
#endif
- if (cpu->exception_index < 0) {
- return false;
- }
+ return false;
}
-
if (cpu->exception_index >= EXCP_INTERRUPT) {
/* exit request from the cpu execution loop */
*ret = cpu->exception_index;
@@ -688,6 +651,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
/* Finally, check if we need to exit to the main loop. */
if (unlikely(qatomic_read(&cpu->exit_request))
|| (icount_enabled()
+ && (cpu->cflags_next_tb == -1 || cpu->cflags_next_tb & CF_USE_ICOUNT)
&& cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0)) {
qatomic_set(&cpu->exit_request, 0);
if (cpu->exception_index == -1) {
--
2.20.1
next prev parent reply other threads:[~2021-02-09 18:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 18:27 [PATCH v1 00/12] fix plugins double counting with mmio, cleanup CF_ flags Alex Bennée
2021-02-09 18:27 ` [PATCH v1 01/12] exec: Move TranslationBlock typedef to qemu/typedefs.h Alex Bennée
2021-02-09 18:27 ` [PATCH v1 02/12] accel/tcg: Create io_recompile_replay_branch hook Alex Bennée
2021-02-09 18:27 ` [PATCH v1 03/12] target/mips: Create mips_io_recompile_replay_branch Alex Bennée
2021-02-09 18:27 ` [PATCH v1 04/12] target/sh4: Create superh_io_recompile_replay_branch Alex Bennée
2021-02-09 18:27 ` [PATCH v1 05/12] tests/plugin: expand insn test to detect duplicate instructions Alex Bennée
2021-02-09 18:34 ` Richard Henderson
2021-02-09 20:48 ` Alex Bennée
2021-02-09 18:27 ` [PATCH v1 06/12] tests/acceptance: add a new set of tests to exercise plugins Alex Bennée
2021-02-09 18:27 ` [PATCH v1 07/12] accel/tcg: actually cache our partial icount TB Alex Bennée
2021-02-09 18:41 ` Richard Henderson
2021-02-09 20:49 ` Alex Bennée
2021-02-09 18:27 ` Alex Bennée [this message]
2021-02-09 18:27 ` [PATCH v1 09/12] accel/tcg: re-factor non-RAM execution code Alex Bennée
2021-02-09 18:27 ` [PATCH v1 10/12] accel/tcg: remove CF_NOCACHE and special cases Alex Bennée
2021-02-09 21:03 ` Richard Henderson
2021-02-09 18:27 ` [PATCH v1 11/12] accel/tcg: allow plugin instrumentation to be disable via cflags Alex Bennée
2021-02-09 21:05 ` Richard Henderson
2021-02-09 18:27 ` [PATCH v1 12/12] tests/acceptance: add a new tests to detect counting errors Alex Bennée
2021-02-11 11:28 ` [PATCH v1 00/12] fix plugins double counting with mmio, cleanup CF_ flags no-reply
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=20210209182749.31323-9-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aaron@os.amperecomputing.com \
--cc=cota@braap.org \
--cc=kuhn.chenqun@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=robhenry@microsoft.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).