@@ -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);
@@ -36,6 +36,7 @@ bool qemu_log_separate(void);
#define LOG_STRACE (1 << 19)
#define LOG_PER_THREAD (1 << 20)
#define CPU_LOG_TB_VPU (1 << 21)
+#define CPU_LOG_TB_STATS (1 << 22)
/* Lock/unlock output. */
@@ -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'))
new file mode 100644
@@ -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;
+}
@@ -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
@@ -497,6 +498,8 @@ const QEMULogItem qemu_log_items[] = {
"open a separate log file per thread; filename must contain '%d'" },
{ CPU_LOG_TB_VPU, "vpu",
"include VPU registers in the 'cpu' logging" },
+ { CPU_LOG_TB_STATS, "tb_stats_{all,jit,exec}",
+ "enable collection of TBs statistics at startup" },
{ 0, NULL, NULL },
};
@@ -518,6 +521,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)) {