[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v15 06/10] tb-stats: reset the tracked TBs on a tb_flush
From: |
Fei Wu |
Subject: |
[PATCH v15 06/10] tb-stats: reset the tracked TBs on a tb_flush |
Date: |
Wed, 7 Jun 2023 20:24:07 +0800 |
From: Alex Bennée <alex.bennee@linaro.org>
We keep track of translations but can only do so up until the
translation cache is flushed. At that point we really have no idea if
we can re-create a translation because all the active tracking
information has been reset.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Fei Wu <fei2.wu@intel.com>
---
accel/tcg/tb-maint.c | 1 +
accel/tcg/tb-stats.c | 18 ++++++++++++++++++
include/exec/tb-stats.h | 8 ++++++++
3 files changed, 27 insertions(+)
diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
index 0980fca358..11ff0ddd90 100644
--- a/accel/tcg/tb-maint.c
+++ b/accel/tcg/tb-maint.c
@@ -763,6 +763,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data
tb_flush_count)
qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE);
tb_remove_all();
+ tbstats_reset_tbs();
tcg_region_reset_all();
/* XXX: flush processor icache at this point if cache flush is expensive */
qatomic_inc(&tb_ctx.tb_flush_count);
diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c
index c90dde37d0..7c7f700c89 100644
--- a/accel/tcg/tb-stats.c
+++ b/accel/tcg/tb-stats.c
@@ -103,6 +103,24 @@ void clean_tbstats(void)
qht_destroy(&tb_ctx.tb_stats);
}
+/*
+ * We have to reset the tbs array on a tb_flush as those
+ * TranslationBlocks no longer exist.
+ */
+
+static void reset_tbs_array(void *p, uint32_t hash, void *userp)
+{
+ TBStatistics *tbs = p;
+ g_ptr_array_set_size(tbs->tbs, 0);
+}
+
+void tbstats_reset_tbs(void)
+{
+ if (tb_ctx.tb_stats.map) {
+ qht_iter(&tb_ctx.tb_stats, reset_tbs_array, NULL);
+ }
+}
+
void init_tb_stats_htable(void)
{
if (!tb_ctx.tb_stats.map && tb_stats_collection_enabled()) {
diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h
index e16f947410..77974b4b7f 100644
--- a/include/exec/tb-stats.h
+++ b/include/exec/tb-stats.h
@@ -94,4 +94,12 @@ void dump_jit_profile_info(GString *buf);
void clean_tbstats(void);
+/**
+ * tbstats_reset_tbs: reset the linked array of TBs
+ *
+ * Reset the list of tbs for a given array. Should be called from
+ * safe work during tb_flush.
+ */
+void tbstats_reset_tbs(void);
+
#endif
--
2.25.1
- [PATCH v15 00/10] TCG code quality tracking, Fei Wu, 2023/06/07
- [PATCH v15 01/10] accel/tcg: remove CONFIG_PROFILER, Fei Wu, 2023/06/07
- [PATCH v15 02/10] accel/tcg: introduce TBStatistics structure, Fei Wu, 2023/06/07
- [PATCH v15 03/10] accel: collecting TB execution count, Fei Wu, 2023/06/07
- [PATCH v15 04/10] accel/tcg: add jit stats to TBStatistics, Fei Wu, 2023/06/07
- [PATCH v15 05/10] monitor: adding tb_stats hmp command, Fei Wu, 2023/06/07
- [PATCH v15 07/10] tb-stats: Adding info [tb-list|tb] commands to HMP (WIP), Fei Wu, 2023/06/07
- [PATCH v15 06/10] tb-stats: reset the tracked TBs on a tb_flush,
Fei Wu <=
- [PATCH v15 09/10] tb-stats: dump hot TBs at the end of the execution, Fei Wu, 2023/06/07
- [PATCH v15 08/10] debug: add -d tb_stats to control TBStatistics, Fei Wu, 2023/06/07
- [PATCH v15 10/10] docs: add tb-stats how to, Fei Wu, 2023/06/07
- Re: [PATCH v15 00/10] TCG code quality tracking, Wu, Fei, 2023/06/12
- Re: [PATCH v15 00/10] TCG code quality tracking, Wu, Fei, 2023/06/12