From: Fei Wu <fei2.wu@intel.com>
To: alex.bennee@linaro.org, richard.henderson@linaro.org,
qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH v11 06/14] accel/tcg: convert profiling of restore operations to TBStats
Date: Fri, 21 Apr 2023 21:24:13 +0800 [thread overview]
Message-ID: <20230421132421.1617479-7-fei2.wu@intel.com> (raw)
In-Reply-To: <20230421132421.1617479-1-fei2.wu@intel.com>
From: Alex Bennée <alex.bennee@linaro.org>
This starts the conversion of CONFIG_PROFILER data collection to under
the TBStats system. We introduce a new flag TB_JIT_TIME and start
tracking how much time is spent restoring execution state from a given
TB.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
accel/tcg/translate-all.c | 23 ++++++++++++++---------
include/exec/tb-stats.h | 6 ++++++
include/qemu/timer.h | 3 ---
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 8a51c291d8..bf10987450 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -200,10 +200,12 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
uintptr_t host_pc)
{
uint64_t data[TARGET_INSN_START_WORDS];
-#ifdef CONFIG_PROFILER
- TCGProfile *prof = &tcg_ctx->prof;
- int64_t ti = profile_getclock();
-#endif
+ uint64_t ti = 0;
+
+ if (tb_stats_enabled(tb, TB_JIT_TIME)) {
+ ti = profile_getclock();
+ }
+
int insns_left = cpu_unwind_data_from_tb(tb, host_pc, data);
if (insns_left < 0) {
@@ -221,11 +223,14 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
cpu->cc->tcg_ops->restore_state_to_opc(cpu, tb, data);
-#ifdef CONFIG_PROFILER
- qatomic_set(&prof->restore_time,
- prof->restore_time + profile_getclock() - ti);
- qatomic_set(&prof->restore_count, prof->restore_count + 1);
-#endif
+ if (tb_stats_enabled(tb, TB_JIT_TIME)) {
+ TBStatistics *ts = tb->tb_stats;
+ uint64_t elapsed = profile_getclock() - ti;
+ qemu_mutex_lock(&ts->jit_stats_lock);
+ ts->tb_restore_time += elapsed;
+ ts->tb_restore_count++;
+ qemu_mutex_unlock(&ts->jit_stats_lock);
+ }
}
bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc)
diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h
index 0ccf025ae4..80314c50f9 100644
--- a/include/exec/tb-stats.h
+++ b/include/exec/tb-stats.h
@@ -91,6 +91,11 @@ struct TBStatistics {
* this TBStats structure. Has to be reset on a tb_flush.
*/
GPtrArray *tbs;
+
+ /* Recover state from TB */
+ uint64_t tb_restore_time;
+ uint64_t tb_restore_count;
+
};
bool tb_stats_cmp(const void *ap, const void *bp);
@@ -102,6 +107,7 @@ void dump_jit_profile_info(TCGProfile *s, GString *buf);
#define TB_NOTHING (1 << 0)
#define TB_EXEC_STATS (1 << 1)
#define TB_JIT_STATS (1 << 2)
+#define TB_JIT_TIME (1 << 3)
void enable_collect_tb_stats(void);
void disable_collect_tb_stats(void);
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index d86fc73a17..ad0da18a5f 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -989,7 +989,6 @@ static inline int64_t cpu_get_host_ticks(void)
}
#endif
-#ifdef CONFIG_PROFILER
static inline int64_t profile_getclock(void)
{
return get_clock();
@@ -997,5 +996,3 @@ static inline int64_t profile_getclock(void)
extern uint64_t dev_time;
#endif
-
-#endif
--
2.25.1
next prev parent reply other threads:[~2023-04-21 13:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 13:24 [PATCH v11 00/14] TCG code quality tracking Fei Wu
2023-04-21 13:24 ` [PATCH v11 01/14] accel/tcg: introduce TBStatistics structure Fei Wu
2023-05-03 8:12 ` Richard Henderson
2023-05-08 9:52 ` Wu, Fei
2023-04-21 13:24 ` [PATCH v11 02/14] accel: collecting TB execution count Fei Wu
2023-05-03 8:28 ` Richard Henderson
2023-05-08 10:02 ` Wu, Fei
2023-04-21 13:24 ` [PATCH v11 03/14] accel: collecting JIT statistics Fei Wu
2023-04-21 13:24 ` [PATCH v11 04/14] accel: replacing part of CONFIG_PROFILER with TBStats Fei Wu
2023-04-21 13:24 ` [PATCH v11 05/14] accel/tcg: move profiler dev_time to tb_stats Fei Wu
2023-04-21 13:24 ` Fei Wu [this message]
2023-04-21 13:24 ` [PATCH v11 07/14] accel/tcg: convert profiling of code generation to TBStats Fei Wu
2023-04-21 13:24 ` [PATCH v11 08/14] accel: adding TB_JIT_TIME and full replacing CONFIG_PROFILER Fei Wu
2023-04-21 13:24 ` [PATCH v11 09/14] debug: add -d tb_stats to control TBStatistics collection: Fei Wu
2023-04-21 13:24 ` [PATCH v11 10/14] monitor: adding tb_stats hmp command Fei Wu
2023-04-21 13:24 ` [PATCH v11 11/14] tb-stats: reset the tracked TBs on a tb_flush Fei Wu
2023-04-21 13:24 ` [PATCH v11 12/14] Adding info [tb-list|tb] commands to HMP (WIP) Fei Wu
2023-04-21 14:43 ` Wu, Fei
2023-04-21 13:24 ` [PATCH v11 13/14] tb-stats: dump hot TBs at the end of the execution Fei Wu
2023-04-21 13:24 ` [PATCH v11 14/14] configure: remove the final bits of --profiler support Fei Wu
2023-04-21 16:42 ` [PATCH v11 00/14] TCG code quality tracking Alex Bennée
2023-05-12 8:07 ` Wu, Fei
2023-05-12 8:42 ` Alex Bennée
2023-05-12 8:58 ` Wu, Fei
2023-05-12 9:29 ` Alex Bennée
2023-05-19 1:16 ` Wu, Fei
2023-05-19 22:01 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230421132421.1617479-7-fei2.wu@intel.com \
--to=fei2.wu@intel.com \
--cc=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).