qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	robhenry@microsoft.com, mahmoudabdalghany@outlook.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 v3 17/23] accel/tcg: cache single instruction TB on pending replay exception
Date: Sat, 13 Feb 2021 13:03:19 +0000	[thread overview]
Message-ID: <20210213130325.14781-18-alex.bennee@linaro.org> (raw)
In-Reply-To: <20210213130325.14781-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>
Message-Id: <20210209182749.31323-9-alex.bennee@linaro.org>
Message-Id: <20210210221053.18050-18-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 d24c1bdb74..16e4fe3ccd 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



  parent reply	other threads:[~2021-02-13 13:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 13:03 [PATCH v3 00/23] plugins/next pre-PR (hwprofile, regression fixes, icount count fix) Alex Bennée
2021-02-13 13:03 ` [PATCH v3 01/23] hw/virtio/pci: include vdev name in registered PCI sections Alex Bennée
2021-02-13 13:03 ` [PATCH v3 02/23] plugins: add API to return a name for a IO device Alex Bennée
2021-02-13 13:03 ` [PATCH v3 03/23] plugins: new hwprofile plugin Alex Bennée
2021-02-13 13:03 ` [PATCH v3 04/23] contrib: Don't use '#' flag of printf format Alex Bennée
2021-02-13 13:03 ` [PATCH v3 05/23] contrib: Fix some code style problems, ERROR: "foo * bar" should be "foo *bar" Alex Bennée
2021-02-13 13:03 ` [PATCH v3 06/23] contrib: Add spaces around operator Alex Bennée
2021-02-13 13:03 ` [PATCH v3 07/23] contrib: space required after that ',' Alex Bennée
2021-02-13 13:03 ` [PATCH v3 08/23] contrib: Open brace '{' following struct go on the same line Alex Bennée
2021-02-13 13:03 ` [PATCH v3 09/23] accel/tcg/plugin-gen: fix the call signature for inline callbacks Alex Bennée
2021-02-13 13:03 ` [PATCH v3 10/23] exec: Move TranslationBlock typedef to qemu/typedefs.h Alex Bennée
2021-02-13 13:03 ` [PATCH v3 11/23] accel/tcg: Create io_recompile_replay_branch hook Alex Bennée
2021-02-13 13:03 ` [PATCH v3 12/23] target/mips: Create mips_io_recompile_replay_branch Alex Bennée
2021-02-13 13:03 ` [PATCH v3 13/23] target/sh4: Create superh_io_recompile_replay_branch Alex Bennée
2021-02-13 13:03 ` [PATCH v3 14/23] tests/plugin: expand insn test to detect duplicate instructions Alex Bennée
2021-02-13 16:26   ` Richard Henderson
2021-02-13 13:03 ` [PATCH v3 15/23] tests/acceptance: add a new set of tests to exercise plugins Alex Bennée
2021-02-13 13:03 ` [PATCH v3 16/23] accel/tcg: actually cache our partial icount TB Alex Bennée
2021-02-13 13:03 ` Alex Bennée [this message]
2021-02-13 16:29   ` [PATCH v3 17/23] accel/tcg: cache single instruction TB on pending replay exception Richard Henderson
2021-02-13 13:03 ` [PATCH v3 18/23] accel/tcg: re-factor non-RAM execution code Alex Bennée
2021-02-13 13:03 ` [PATCH v3 19/23] accel/tcg: remove CF_NOCACHE and special cases Alex Bennée
2021-02-13 13:03 ` [PATCH v3 20/23] accel/tcg: allow plugin instrumentation to be disable via cflags Alex Bennée
2021-02-17 16:30   ` Aaron Lindsay via
2021-02-13 13:03 ` [PATCH v3 21/23] tests/acceptance: add a new tests to detect counting errors Alex Bennée
2021-02-13 13:03 ` [PATCH v3 22/23] tests/plugin: allow memory plugin to do both inline and callbacks Alex Bennée
2021-02-17 17:43   ` Philippe Mathieu-Daudé
2021-02-17 19:59   ` Richard Henderson
2021-02-13 13:03 ` [PATCH v3 23/23] tests/acceptance: add a memory callback check Alex Bennée
2021-02-13 14:17   ` Philippe Mathieu-Daudé

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=20210213130325.14781-18-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=aaron@os.amperecomputing.com \
    --cc=cota@braap.org \
    --cc=kuhn.chenqun@huawei.com \
    --cc=mahmoudabdalghany@outlook.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).