[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v11 11/14] tb-stats: reset the tracked TBs on a tb_flush
From: |
Fei Wu |
Subject: |
[PATCH v11 11/14] tb-stats: reset the tracked TBs on a tb_flush |
Date: |
Fri, 21 Apr 2023 21:24:18 +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>
---
accel/tcg/tb-maint.c | 1 +
accel/tcg/tb-stats.c | 19 +++++++++++++++++++
include/exec/tb-stats.h | 8 ++++++++
3 files changed, 28 insertions(+)
diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
index ba1635aa4b..5f946e0285 100644
--- a/accel/tcg/tb-maint.c
+++ b/accel/tcg/tb-maint.c
@@ -762,6 +762,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_mb_set(&tb_ctx.tb_flush_count, tb_ctx.tb_flush_count + 1);
diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c
index 61bfbe96fc..56e944b225 100644
--- a/accel/tcg/tb-stats.c
+++ b/accel/tcg/tb-stats.c
@@ -269,6 +269,25 @@ void do_hmp_tbstats_safe(CPUState *cpu, run_on_cpu_data
icmd)
g_free(cmdinfo);
}
+/*
+ * We have to reset the tbs array on a tb_flush as those
+ * TranslationBlocks no longer exist and we no loner know if the
+ * current mapping is still valid.
+ */
+
+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 33eed8d385..ec47cbecc2 100644
--- a/include/exec/tb-stats.h
+++ b/include/exec/tb-stats.h
@@ -125,4 +125,12 @@ struct TbstatsCommand {
void do_hmp_tbstats_safe(CPUState *cpu, run_on_cpu_data icmd);
+/**
+ * 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 v11 01/14] accel/tcg: introduce TBStatistics structure, (continued)
- [PATCH v11 01/14] accel/tcg: introduce TBStatistics structure, Fei Wu, 2023/04/21
- [PATCH v11 02/14] accel: collecting TB execution count, Fei Wu, 2023/04/21
- [PATCH v11 03/14] accel: collecting JIT statistics, Fei Wu, 2023/04/21
- [PATCH v11 04/14] accel: replacing part of CONFIG_PROFILER with TBStats, Fei Wu, 2023/04/21
- [PATCH v11 05/14] accel/tcg: move profiler dev_time to tb_stats, Fei Wu, 2023/04/21
- [PATCH v11 06/14] accel/tcg: convert profiling of restore operations to TBStats, Fei Wu, 2023/04/21
- [PATCH v11 07/14] accel/tcg: convert profiling of code generation to TBStats, Fei Wu, 2023/04/21
- [PATCH v11 08/14] accel: adding TB_JIT_TIME and full replacing CONFIG_PROFILER, Fei Wu, 2023/04/21
- [PATCH v11 09/14] debug: add -d tb_stats to control TBStatistics collection:, Fei Wu, 2023/04/21
- [PATCH v11 10/14] monitor: adding tb_stats hmp command, Fei Wu, 2023/04/21
- [PATCH v11 11/14] tb-stats: reset the tracked TBs on a tb_flush,
Fei Wu <=
- [PATCH v11 12/14] Adding info [tb-list|tb] commands to HMP (WIP), Fei Wu, 2023/04/21
- [PATCH v11 13/14] tb-stats: dump hot TBs at the end of the execution, Fei Wu, 2023/04/21
- [PATCH v11 14/14] configure: remove the final bits of --profiler support, Fei Wu, 2023/04/21
- Re: [PATCH v11 00/14] TCG code quality tracking, Alex Bennée, 2023/04/21