[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v17 06/16] accel/tcg: Collect TB execution statistics
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v17 06/16] accel/tcg: Collect TB execution statistics |
|
Date: |
Tue, 3 Oct 2023 11:30:48 -0700 |
From: "Vanderson M. do Rosario" <vandersonmr2@gmail.com>
Collect atomic and normal execution counts for TBs which
have allocated a stats structure.
Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Fei Wu <fei2.wu@intel.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/cpu-exec.c | 6 ++++++
accel/tcg/translator.c | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 1a5bc90220..1114eae5c4 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -26,6 +26,7 @@
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg/tcg.h"
+#include "tcg/tb-stats.h"
#include "qemu/atomic.h"
#include "qemu/rcu.h"
#include "exec/log.h"
@@ -601,6 +602,11 @@ void cpu_exec_step_atomic(CPUState *cpu)
}
cpu_exec_enter(cpu);
+
+ if (tb_stats_enabled_for_tb(tb, TB_STATS_EXEC)) {
+ tb->tb_stats->executions.atomic++;
+ }
+
/* execute the generated code */
trace_exec_tb(tb, pc);
cpu_tb_exec(cpu, tb, &tb_exit);
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index e7abcd86c1..eac281b229 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -14,6 +14,8 @@
#include "exec/translator.h"
#include "exec/plugin-gen.h"
#include "tcg/tcg-op-common.h"
+#include "tcg/tcg-temp-internal.h"
+#include "tcg/tb-stats.h"
#include "internal-target.h"
static void set_can_do_io(DisasContextBase *db, bool val)
@@ -112,6 +114,31 @@ static void gen_tb_end(const TranslationBlock *tb,
uint32_t cflags,
}
}
+static void gen_tb_exec_count(TranslationBlock *tb)
+{
+ if (tb_stats_enabled_for_tb(tb, TB_STATS_EXEC)) {
+ TCGv_ptr ptr = tcg_temp_ebb_new_ptr();
+
+ tcg_gen_movi_ptr(ptr, (intptr_t)&tb->tb_stats->executions.normal);
+ if (sizeof(tb->tb_stats->executions.normal) == 4) {
+ TCGv_i32 t = tcg_temp_ebb_new_i32();
+ tcg_gen_ld_i32(t, ptr, 0);
+ tcg_gen_addi_i32(t, t, 1);
+ tcg_gen_st_i32(t, ptr, 0);
+ tcg_temp_free_i32(t);
+ } else if (sizeof(tb->tb_stats->executions.normal) == 8) {
+ TCGv_i64 t = tcg_temp_ebb_new_i64();
+ tcg_gen_ld_i64(t, ptr, 0);
+ tcg_gen_addi_i64(t, t, 1);
+ tcg_gen_st_i64(t, ptr, 0);
+ tcg_temp_free_i64(t);
+ } else {
+ qemu_build_not_reached_always();
+ }
+ tcg_temp_free_ptr(ptr);
+ }
+}
+
bool translator_use_goto_tb(DisasContextBase *db, vaddr dest)
{
/* Suppress goto_tb if requested. */
@@ -148,6 +175,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb,
int *max_insns,
/* Start translating. */
icount_start_insn = gen_tb_start(db, cflags);
+ gen_tb_exec_count(tb);
ops->tb_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
--
2.34.1
- Re: [PATCH v17 03/16] tcg: Record nb_deleted_ops in TCGContext, (continued)
- [PATCH v17 02/16] tcg: Record orig_nb_ops TCGContext, Richard Henderson, 2023/10/03
- [PATCH v17 08/16] accel/tcg: Add tb_stats hmp command, Richard Henderson, 2023/10/03
- [PATCH v17 05/16] accel/tcg: Add TBStatistics structure, Richard Henderson, 2023/10/03
- [PATCH v17 07/16] accel/tcg: Collect TB jit statistics, Richard Henderson, 2023/10/03
- [PATCH v17 04/16] tcg: Record nb_spills in TCGContext, Richard Henderson, 2023/10/03
- [PATCH v17 06/16] accel/tcg: Collect TB execution statistics,
Richard Henderson <=
- [PATCH v17 11/16] accel/tcg: Add tb_stats_collect and tb_stats_dump, Richard Henderson, 2023/10/03
- [PATCH v17 12/16] softmmu: Export qemu_ram_ptr_length, Richard Henderson, 2023/10/03
- [PATCH v17 13/16] disas: Allow monitor_disas to read from ram_addr_t, Richard Henderson, 2023/10/03
- [PATCH v17 10/16] util/log: Add -d tb_stats, Richard Henderson, 2023/10/03