From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Liren Wei <lrwei@bupt.edu.cn>
Subject: [PATCH 04/41] tcg: Bake tb_destroy() into tcg_region_tree
Date: Sat, 10 Jul 2021 08:31:06 -0700 [thread overview]
Message-ID: <20210710153143.1320521-5-richard.henderson@linaro.org> (raw)
In-Reply-To: <20210710153143.1320521-1-richard.henderson@linaro.org>
From: Liren Wei <lrwei@bupt.edu.cn>
The function is called only at tcg_gen_code() when duplicated TBs
are translated by different threads, and when the tcg_region_tree
is reset. Bake it into the underlying GTree as its value destroy
function to unite these situations.
Also remove tcg_region_tree_traverse() which now becomes useless.
Signed-off-by: Liren Wei <lrwei@bupt.edu.cn>
Message-Id: <8dc352f08d038c4e7a1f5f56962398cdc700c3aa.1625404483.git.lrwei@bupt.edu.cn>
[rth: Name the new tb_tc_cmp parameter correctly.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/tcg/tcg.h | 1 -
accel/tcg/translate-all.c | 6 ------
tcg/region.c | 19 ++++++++-----------
3 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 899493701c..dedb86939a 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -808,7 +808,6 @@ void *tcg_malloc_internal(TCGContext *s, int size);
void tcg_pool_reset(TCGContext *s);
TranslationBlock *tcg_tb_alloc(TCGContext *s);
-void tb_destroy(TranslationBlock *tb);
void tcg_region_reset_all(void);
size_t tcg_code_size(void);
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 75e4d06557..57455d8639 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -378,11 +378,6 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
return 0;
}
-void tb_destroy(TranslationBlock *tb)
-{
- qemu_spin_destroy(&tb->jmp_lock);
-}
-
bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit)
{
/*
@@ -1681,7 +1676,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
orig_aligned -= ROUND_UP(sizeof(*tb), qemu_icache_linesize);
qatomic_set(&tcg_ctx->code_gen_ptr, (void *)orig_aligned);
- tb_destroy(tb);
tcg_tb_remove(tb);
return existing_tb;
}
diff --git a/tcg/region.c b/tcg/region.c
index 00b0c3b091..d3a3658e81 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -112,7 +112,7 @@ static int ptr_cmp_tb_tc(const void *ptr, const struct tb_tc *s)
return 0;
}
-static gint tb_tc_cmp(gconstpointer ap, gconstpointer bp)
+static gint tb_tc_cmp(gconstpointer ap, gconstpointer bp, gpointer userdata)
{
const struct tb_tc *a = ap;
const struct tb_tc *b = bp;
@@ -143,6 +143,12 @@ static gint tb_tc_cmp(gconstpointer ap, gconstpointer bp)
return ptr_cmp_tb_tc(b->ptr, a);
}
+static void tb_destroy(gpointer value)
+{
+ TranslationBlock *tb = value;
+ qemu_spin_destroy(&tb->jmp_lock);
+}
+
static void tcg_region_trees_init(void)
{
size_t i;
@@ -153,7 +159,7 @@ static void tcg_region_trees_init(void)
struct tcg_region_tree *rt = region_trees + i * tree_size;
qemu_mutex_init(&rt->lock);
- rt->tree = g_tree_new(tb_tc_cmp);
+ rt->tree = g_tree_new_full(tb_tc_cmp, NULL, NULL, tb_destroy);
}
}
@@ -277,14 +283,6 @@ size_t tcg_nb_tbs(void)
return nb_tbs;
}
-static gboolean tcg_region_tree_traverse(gpointer k, gpointer v, gpointer data)
-{
- TranslationBlock *tb = v;
-
- tb_destroy(tb);
- return FALSE;
-}
-
static void tcg_region_tree_reset_all(void)
{
size_t i;
@@ -293,7 +291,6 @@ static void tcg_region_tree_reset_all(void)
for (i = 0; i < region.n; i++) {
struct tcg_region_tree *rt = region_trees + i * tree_size;
- g_tree_foreach(rt->tree, tcg_region_tree_traverse, NULL);
/* Increment the refcount first so that destroy acts as a reset */
g_tree_ref(rt->tree);
g_tree_destroy(rt->tree);
--
2.25.1
next prev parent reply other threads:[~2021-07-10 15:34 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-10 15:31 [PATCH 00/41] tcg patch queue Richard Henderson
2021-07-10 15:31 ` [PATCH 01/41] tcg: Add separator in INDEX_op_call dump Richard Henderson
2021-07-10 15:31 ` [PATCH 02/41] tcg: Avoid including 'trace-tcg.h' in target translate.c Richard Henderson
2021-07-10 15:31 ` [PATCH 03/41] accel/tcg: Hoist tcg_tb_insert() up above tb_link_page() Richard Henderson
2021-07-10 15:31 ` Richard Henderson [this message]
2021-07-10 15:31 ` [PATCH 05/41] tcg: Move tb_phys_invalidate_count to tb_ctx Richard Henderson
2021-07-10 15:31 ` [PATCH 06/41] accel/tcg: Introduce translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 07/41] target/alpha: Remove use_exit_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 08/41] target/alpha: Remove in_superpage Richard Henderson
2021-07-10 15:31 ` [PATCH 09/41] target/alpha: Use translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 10/41] target/arm: Use DISAS_TOO_MANY for ISB and SB Richard Henderson
2021-07-10 15:31 ` [PATCH 11/41] target/arm: Use translator_use_goto_tb for aarch64 Richard Henderson
2021-07-10 15:31 ` [PATCH 12/41] target/arm: Use translator_use_goto_tb for aarch32 Richard Henderson
2021-07-10 15:31 ` [PATCH 13/41] target/avr: Use translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 14/41] target/avr: Mark some helpers noreturn Richard Henderson
2021-07-10 15:31 ` [PATCH 15/41] target/cris: Use translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 16/41] target/hppa: " Richard Henderson
2021-07-10 15:31 ` [PATCH 17/41] target/i386: " Richard Henderson
2021-07-10 15:31 ` [PATCH 18/41] target/m68k: " Richard Henderson
2021-07-10 15:31 ` [PATCH 19/41] target/microblaze: " Richard Henderson
2021-07-10 15:31 ` [PATCH 20/41] target/mips: " Richard Henderson
2021-07-10 15:31 ` [PATCH 21/41] target/mips: Fix missing else in gen_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 22/41] target/nios2: Use translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 23/41] target/openrisc: " Richard Henderson
2021-07-10 15:31 ` [PATCH 24/41] target/ppc: " Richard Henderson
2021-07-10 15:31 ` [PATCH 25/41] target/riscv: " Richard Henderson
2021-07-10 15:31 ` [PATCH 26/41] target/rx: " Richard Henderson
2021-07-10 15:31 ` [PATCH 27/41] target/s390x: " Richard Henderson
2021-07-10 15:31 ` [PATCH 28/41] target/s390x: Remove use_exit_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 29/41] target/sh4: Use translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 30/41] target/sparc: " Richard Henderson
2021-07-10 15:31 ` [PATCH 31/41] target/tricore: " Richard Henderson
2021-07-10 15:31 ` [PATCH 32/41] target/tricore: Use tcg_gen_lookup_and_goto_ptr Richard Henderson
2021-07-10 15:31 ` [PATCH 33/41] target/xtensa: Use translator_use_goto_tb Richard Henderson
2021-07-10 15:31 ` [PATCH 34/41] tcg: Fix prologue disassembly Richard Henderson
2021-07-10 15:31 ` [PATCH 35/41] target/i386: Use cpu_breakpoint_test in breakpoint_handler Richard Henderson
2021-07-10 15:31 ` [PATCH 36/41] accel/tcg: Move helper_lookup_tb_ptr to cpu-exec.c Richard Henderson
2021-07-10 15:31 ` [PATCH 37/41] accel/tcg: Move tb_lookup " Richard Henderson
2021-07-10 15:31 ` [PATCH 38/41] accel/tcg: Split out log_cpu_exec Richard Henderson
2021-07-10 15:31 ` [PATCH 39/41] accel/tcg: Log tb->cflags with -d exec Richard Henderson
2021-07-10 15:31 ` [PATCH 40/41] tcg: Remove TCG_TARGET_HAS_goto_ptr Richard Henderson
2021-07-10 15:31 ` [PATCH 41/41] cpu: Add breakpoint tracepoints Richard Henderson
2021-07-10 16:24 ` [PATCH 00/41] tcg patch queue Peter Maydell
2021-07-11 0:12 ` Richard Henderson
2021-07-12 11:53 ` Peter Maydell
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=20210710153143.1320521-5-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=lrwei@bupt.edu.cn \
--cc=qemu-devel@nongnu.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).