Emilio G. Cota <c...@braap.org> writes: > Whenever there is an overflow in code_gen_buffer (e.g. we run out > of space in it and have to flush it), the code_time profiling counter > ends up with an invalid value (that is, code_time -= profile_getclock(), > without later on getting += profile_getclock() due to the goto). > > Fix it by using the ti variable, so that we only update code_time > when there is no overflow. Note that in case there is an overflow > we fail to account for the elapsed coding time, but this is quite rare > so we can probably live with it. > <snip> > > Signed-off-by: Emilio G. Cota <c...@braap.org>
Reviewed-by: Alex Bennée <alex.ben...@linaro.org> > --- > accel/tcg/translate-all.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c > index a936a5f..72ce445 100644 > --- a/accel/tcg/translate-all.c > +++ b/accel/tcg/translate-all.c > @@ -1293,7 +1293,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, > #ifdef CONFIG_PROFILER > tcg_ctx.tb_count++; > tcg_ctx.interm_time += profile_getclock() - ti; > - tcg_ctx.code_time -= profile_getclock(); > + ti = profile_getclock(); > #endif > > /* ??? Overflow could be handled better here. In particular, we > @@ -1311,7 +1311,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, > } > > #ifdef CONFIG_PROFILER > - tcg_ctx.code_time += profile_getclock(); > + tcg_ctx.code_time += profile_getclock() - ti; > tcg_ctx.code_in_len += tb->size; > tcg_ctx.code_out_len += gen_code_size; > tcg_ctx.search_out_len += search_size; -- Alex Bennée