[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v15 08/10] debug: add -d tb_stats to control TBStatistics
From: |
Fei Wu |
Subject: |
[PATCH v15 08/10] debug: add -d tb_stats to control TBStatistics |
Date: |
Wed, 7 Jun 2023 20:24:09 +0800 |
Capture TBS at startup instead of an explicit 'tb_stats start' command.
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>
---
include/exec/tb-stats-flags.h | 1 +
include/qemu/log.h | 1 +
stubs/meson.build | 1 +
stubs/tb-stats.c | 32 ++++++++++++++++++++++++++++++++
util/log.c | 18 ++++++++++++++++++
5 files changed, 53 insertions(+)
create mode 100644 stubs/tb-stats.c
diff --git a/include/exec/tb-stats-flags.h b/include/exec/tb-stats-flags.h
index d8b844be99..936bd35707 100644
--- a/include/exec/tb-stats-flags.h
+++ b/include/exec/tb-stats-flags.h
@@ -14,6 +14,7 @@
#define TB_NONE_STATS (0) /* no stats */
#define TB_EXEC_STATS (1 << 0)
#define TB_JIT_STATS (1 << 1)
+#define TB_ALL_STATS (TB_EXEC_STATS | TB_JIT_STATS)
/* TBStatistic collection controls */
void enable_collect_tb_stats(void);
diff --git a/include/qemu/log.h b/include/qemu/log.h
index c5643d8dd5..6f3b8091cd 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -35,6 +35,7 @@ bool qemu_log_separate(void);
/* LOG_STRACE is used for user-mode strace logging. */
#define LOG_STRACE (1 << 19)
#define LOG_PER_THREAD (1 << 20)
+#define CPU_LOG_TB_STATS (1 << 21)
/* Lock/unlock output. */
diff --git a/stubs/meson.build b/stubs/meson.build
index a56645e2f7..e926649d40 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -65,3 +65,4 @@ else
endif
stub_ss.add(files('semihost-all.c'))
stub_ss.add(when: 'CONFIG_VFIO_USER_SERVER', if_false:
files('vfio-user-obj.c'))
+stub_ss.add(files('tb-stats.c'))
diff --git a/stubs/tb-stats.c b/stubs/tb-stats.c
new file mode 100644
index 0000000000..38ee12313e
--- /dev/null
+++ b/stubs/tb-stats.c
@@ -0,0 +1,32 @@
+/*
+ * TB Stats Stubs
+ *
+ * Copyright (c) 2019
+ * Written by Alex Bennée <alex.bennee@linaro.org>
+ *
+ * This code is licensed under the GNU GPL v2, or later.
+ */
+
+
+#include "qemu/osdep.h"
+#include "exec/tb-stats-flags.h"
+
+void enable_collect_tb_stats(void)
+{
+ return;
+}
+
+void disable_collect_tb_stats(void)
+{
+ return;
+}
+
+bool tb_stats_collection_enabled(void)
+{
+ return false;
+}
+
+void set_tbstats_flag(uint32_t flag)
+{
+ return;
+}
diff --git a/util/log.c b/util/log.c
index 53b4f6c58e..419f02c380 100644
--- a/util/log.c
+++ b/util/log.c
@@ -27,6 +27,7 @@
#include "qemu/thread.h"
#include "qemu/lockable.h"
#include "qemu/rcu.h"
+#include "exec/tb-stats-flags.h"
#ifdef CONFIG_LINUX
#include <sys/syscall.h>
#endif
@@ -495,6 +496,8 @@ const QEMULogItem qemu_log_items[] = {
"log every user-mode syscall, its input, and its result" },
{ LOG_PER_THREAD, "tid",
"open a separate log file per thread; filename must contain '%d'" },
+ { CPU_LOG_TB_STATS, "tb_stats_{all,jit,exec}",
+ "enable collection of TBs statistics at startup" },
{ 0, NULL, NULL },
};
@@ -516,6 +519,21 @@ int qemu_str_to_log_mask(const char *str)
trace_enable_events((*tmp) + 6);
mask |= LOG_TRACE;
#endif
+ } else if (g_str_has_prefix(*tmp, "tb_stats_")) {
+ char *p = *tmp + 9;
+ uint32_t flag = TB_NONE_STATS;
+ if (g_str_has_prefix(p, "all")) {
+ flag = TB_ALL_STATS;
+ } else if (g_str_has_prefix(p, "jit")) {
+ flag = TB_JIT_STATS;
+ } else if (g_str_has_prefix(p, "exec")) {
+ flag = TB_EXEC_STATS;
+ }
+ if (flag != TB_NONE_STATS) {
+ mask |= CPU_LOG_TB_STATS;
+ set_tbstats_flag(flag);
+ enable_collect_tb_stats();
+ }
} else {
for (item = qemu_log_items; item->mask != 0; item++) {
if (g_str_equal(*tmp, item->name)) {
--
2.25.1
- [PATCH v15 02/10] accel/tcg: introduce TBStatistics structure, (continued)
- [PATCH v15 02/10] accel/tcg: introduce TBStatistics structure, Fei Wu, 2023/06/07
- [PATCH v15 03/10] accel: collecting TB execution count, Fei Wu, 2023/06/07
- [PATCH v15 04/10] accel/tcg: add jit stats to TBStatistics, Fei Wu, 2023/06/07
- [PATCH v15 05/10] monitor: adding tb_stats hmp command, Fei Wu, 2023/06/07
- [PATCH v15 07/10] tb-stats: Adding info [tb-list|tb] commands to HMP (WIP), Fei Wu, 2023/06/07
- [PATCH v15 06/10] tb-stats: reset the tracked TBs on a tb_flush, Fei Wu, 2023/06/07
- [PATCH v15 09/10] tb-stats: dump hot TBs at the end of the execution, Fei Wu, 2023/06/07
- [PATCH v15 08/10] debug: add -d tb_stats to control TBStatistics,
Fei Wu <=
- [PATCH v15 10/10] docs: add tb-stats how to, Fei Wu, 2023/06/07
- Re: [PATCH v15 00/10] TCG code quality tracking, Wu, Fei, 2023/06/12
- Re: [PATCH v15 00/10] TCG code quality tracking, Wu, Fei, 2023/06/12