[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 04/22] tcg: fix corruption of code_time profilin
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [PATCH 04/22] tcg: fix corruption of code_time profiling counter upon tb_flush |
Date: |
Wed, 12 Jul 2017 15:36:36 +0100 |
User-agent: |
mu4e 0.9.19; emacs 25.2.50.3 |
Emilio G. Cota <address@hidden> 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 <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
> ---
> 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
- [Qemu-devel] [PATCH 08/22] tcg/mips: constify tcg_target_callee_save_regs, (continued)
- [Qemu-devel] [PATCH 08/22] tcg/mips: constify tcg_target_callee_save_regs, Emilio G. Cota, 2017/07/09
- [Qemu-devel] [PATCH 02/22] translate-all: remove redundant !tcg_enabled check in dump_exec_info, Emilio G. Cota, 2017/07/09
- [Qemu-devel] [PATCH 04/22] tcg: fix corruption of code_time profiling counter upon tb_flush, Emilio G. Cota, 2017/07/09
- [Qemu-devel] [PATCH 14/22] tcg: take .helpers out of TCGContext, Emilio G. Cota, 2017/07/09
- [Qemu-devel] [PATCH 09/22] exec-all: shrink tb->invalid to uint8_t, Emilio G. Cota, 2017/07/09