[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Qemu-Devel][PATCH 1/3] Adding an optional tb execution
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [Qemu-Devel][PATCH 1/3] Adding an optional tb execution counter. |
Date: |
Sun, 16 Jun 2019 19:28:11 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 6/14/19 6:53 AM, vandersonmr wrote:
> +void HELPER(inc_exec_freq)(void *ptr)
> +{
> + TranslationBlock* tb = (TranslationBlock*) ptr;
> + atomic_inc(&tb->exec_freq);
> +}
...
> +DEF_HELPER_FLAGS_1(inc_exec_freq, TCG_CALL_NO_RWG, void, ptr)
...
> uint32_t flags; /* flags defining in which context the code was
> generated */
> uint16_t size; /* size of target code for this block (1 <=
> size <= TARGET_PAGE_SIZE) */
> + uint64_t exec_freq;
It's not a frequency, but a count.
> uint16_t icount;
> uint32_t cflags; /* compile flags */
Consider where you've placed the data with respect to the packing of other
members of the structure.
> static inline void gen_tb_start(TranslationBlock *tb)
> {
> TCGv_i32 count, imm;
>
> + if (enable_freq_count) {
> + TCGv_ptr tb_ptr = tcg_temp_new_ptr();
> + tcg_gen_trunc_i64_ptr(tb_ptr, tcg_const_i64((int64_t) tb));
> + gen_helper_inc_exec_freq(tb_ptr);
> + }
> +
> tcg_ctx->exitreq_label = gen_new_label();
> if (tb_cflags(tb) & CF_USE_ICOUNT) {
> count = tcg_temp_local_new_i32();
By placing the increment before the exit for interrupt check instead of after,
you're kinda counting the wrong thing, because the TB hasn't executed.
> diff --git a/linux-user/main.c b/linux-user/main.c
> index a59ae9439d..1bf7155670 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -58,6 +58,7 @@ static const char *seed_optarg;
> unsigned long mmap_min_addr;
> unsigned long guest_base;
> int have_guest_base;
> +bool enable_freq_count = false;
This is being declared in multiple places and initialized in multiple places.
This needs to go elsewhere.
r~
- [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency, vandersonmr, 2019/06/14
- [Qemu-devel] [Qemu-Devel][PATCH 1/3] Adding an optional tb execution counter., vandersonmr, 2019/06/14
- [Qemu-devel] [Qemu-Devel][PATCH 2/3] Saving counters between tb_flush events., vandersonmr, 2019/06/14
- [Qemu-devel] [Qemu-Devel][PATCH 3/3] Adding command line option to linux-user., vandersonmr, 2019/06/14
- Re: [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency, no-reply, 2019/06/14
- Re: [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency, Alex Bennée, 2019/06/17
- Re: [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency, Alex Bennée, 2019/06/17