mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
tcg: distribute profiling counters across TCGContext's
This is groundwork for supporting multiple TCG contexts. To avoid scalability issues when profiling info is enabled, this patch makes the profiling info counters distributed via the following changes: 1) Consolidate profile info into its own struct, TCGProfile, which TCGContext also includes. Note that tcg_table_op_count is brought into TCGProfile after dropping the tcg_ prefix. 2) Iterate over the TCG contexts in the system to obtain the total counts. This change also requires updating the accessors to TCGProfile fields to use atomic_read/set whenever there may be conflicting accesses (as defined in C11) to them. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
df2cce2968
commit
c3fac1138e
3 changed files with 126 additions and 45 deletions
|
@ -310,6 +310,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
|
|||
uint8_t *p = tb->tc.ptr + tb->tc.size;
|
||||
int i, j, num_insns = tb->icount;
|
||||
#ifdef CONFIG_PROFILER
|
||||
TCGProfile *prof = &tcg_ctx->prof;
|
||||
int64_t ti = profile_getclock();
|
||||
#endif
|
||||
|
||||
|
@ -344,8 +345,9 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
|
|||
restore_state_to_opc(env, tb, data);
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
tcg_ctx->restore_time += profile_getclock() - ti;
|
||||
tcg_ctx->restore_count++;
|
||||
atomic_set(&prof->restore_time,
|
||||
prof->restore_time + profile_getclock() - ti);
|
||||
atomic_set(&prof->restore_count, prof->restore_count + 1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -1300,6 +1302,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
tcg_insn_unit *gen_code_buf;
|
||||
int gen_code_size, search_size;
|
||||
#ifdef CONFIG_PROFILER
|
||||
TCGProfile *prof = &tcg_ctx->prof;
|
||||
int64_t ti;
|
||||
#endif
|
||||
assert_memory_lock();
|
||||
|
@ -1327,8 +1330,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
tcg_ctx->tb_cflags = cflags;
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
tcg_ctx->tb_count1++; /* includes aborted translations because of
|
||||
exceptions */
|
||||
/* includes aborted translations because of exceptions */
|
||||
atomic_set(&prof->tb_count1, prof->tb_count1 + 1);
|
||||
ti = profile_getclock();
|
||||
#endif
|
||||
|
||||
|
@ -1353,8 +1356,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
tcg_ctx->tb_count++;
|
||||
tcg_ctx->interm_time += profile_getclock() - ti;
|
||||
atomic_set(&prof->tb_count, prof->tb_count + 1);
|
||||
atomic_set(&prof->interm_time, prof->interm_time + profile_getclock() - ti);
|
||||
ti = profile_getclock();
|
||||
#endif
|
||||
|
||||
|
@ -1374,10 +1377,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
tb->tc.size = gen_code_size;
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
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;
|
||||
atomic_set(&prof->code_time, prof->code_time + profile_getclock() - ti);
|
||||
atomic_set(&prof->code_in_len, prof->code_in_len + tb->size);
|
||||
atomic_set(&prof->code_out_len, prof->code_out_len + gen_code_size);
|
||||
atomic_set(&prof->search_out_len, prof->search_out_len + search_size);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_DISAS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue