Message ID | 20191007152839.30804-9-alex.bennee@linaro.org |
---|---|
State | New |
Headers | show |
Series | TCG code quality tracking and perf integration | expand |
On 10/7/19 11:28 AM, Alex Bennée wrote: > 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> > --- > accel/tcg/tb-stats.c | 19 +++++++++++++++++++ > accel/tcg/translate-all.c | 2 +- > include/exec/tb-stats.h | 8 ++++++++ > 3 files changed, 28 insertions(+), 1 deletion(-) I still don't understand what the tbs array is for, but resetting it at flush is fine. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
Richard Henderson <richard.henderson@linaro.org> writes: > On 10/7/19 11:28 AM, Alex Bennée wrote: >> 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> >> --- >> accel/tcg/tb-stats.c | 19 +++++++++++++++++++ >> accel/tcg/translate-all.c | 2 +- >> include/exec/tb-stats.h | 8 ++++++++ >> 3 files changed, 28 insertions(+), 1 deletion(-) > > I still don't understand what the tbs array is for, > but resetting it at flush is fine. In Vanderson's original patch he kept a reference to the last translated tb which was incorrect - I changed it to track all the TBs associated with the stats entry. However the coverset and cfg commands aren't in this series which needed to iterate down through the TBs to their jump targets to build the full hot block. I suspect for now we can just drop the entry. > > Reviewed-by: Richard Henderson <richard.henderson@linaro.org> > > > r~ -- Alex Bennée
diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index dabc5150f9..f08e5f2540 100644 --- a/accel/tcg/tb-stats.c +++ b/accel/tcg/tb-stats.c @@ -247,6 +247,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_if_not(void) { if (tb_stats_collection_enabled() && !tb_ctx.tb_stats.map) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 396e63c3e7..871d91d559 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1273,7 +1273,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); page_flush_tb(); - + tbstats_reset_tbs(); tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is expensive */ diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 921da38c97..c20a3e6439 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
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> --- accel/tcg/tb-stats.c | 19 +++++++++++++++++++ accel/tcg/translate-all.c | 2 +- include/exec/tb-stats.h | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) -- 2.20.1