@@ -3,6 +3,7 @@
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg.h"
+#include "qemu-common.h"
#include "qemu/qemu-print.h"
@@ -16,6 +16,7 @@
#include "exec/gen-icount.h"
#include "exec/log.h"
#include "exec/translator.h"
+#include "qemu-common.h"
/* Pairs with tcg_clear_temp_count.
To be called by #TranslatorOps.{translate_insn,tb_stop} if
@@ -2,6 +2,7 @@
#define GEN_ICOUNT_H
#include "qemu/timer.h"
+#include "qemu-common.h"
/* Helpers for instruction counting code generation. */
@@ -79,21 +79,6 @@ void init_tb_stats_htable_if_not(void);
void dump_jit_profile_info(TCGProfile *s);
/* TBStatistic collection controls */
-enum TBStatsStatus {
- TB_STATS_DISABLED = 0,
- TB_STATS_RUNNING,
- TB_STATS_PAUSED,
- TB_STATS_STOPPED
-};
-
-#define TB_NOTHING 0
-#define TB_EXEC_STATS 1
-#define TB_JIT_STATS 2
-#define TB_JIT_TIME 4
-
-extern int tcg_collect_tb_stats;
-extern uint32_t default_tbstats_flag;
-
void enable_collect_tb_stats(void);
void disable_collect_tb_stats(void);
void pause_collect_tb_stats(void);
@@ -130,4 +130,19 @@ void page_size_init(void);
* returned. */
bool dump_in_progress(void);
+enum TBStatsStatus {
+ TB_STATS_DISABLED = 0,
+ TB_STATS_RUNNING,
+ TB_STATS_PAUSED,
+ TB_STATS_STOPPED
+};
+
+#define TB_NOTHING 0
+#define TB_EXEC_STATS 1
+#define TB_JIT_STATS 2
+#define TB_JIT_TIME 4
+
+extern int tcg_collect_tb_stats;
+extern uint32_t default_tbstats_flag;
+
#endif
@@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void)
/* LOG_TRACE (1 << 15) is defined in log-for-trace.h */
#define CPU_LOG_TB_OP_IND (1 << 16)
#define CPU_LOG_TB_FPU (1 << 17)
+#define CPU_LOG_TB_STATS (1 << 18)
/* Lock output for a series of related logs. Since this is not needed
* for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we
@@ -35,6 +35,7 @@
#include "qemu/host-utils.h"
#include "qemu/qemu-print.h"
#include "qemu/timer.h"
+#include "qemu-common.h"
/* Note: the long term plan is to reduce the dependencies on the QEMU
CPU definitions. Currently they are used for qemu_ld/st
@@ -19,17 +19,20 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
+#include "qemu/qemu-print.h"
#include "qemu/range.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu/cutils.h"
#include "trace/control.h"
+#include "qemu-common.h"
static char *logfilename;
FILE *qemu_logfile;
int qemu_loglevel;
static int log_append = 0;
static GArray *debug_regions;
+int32_t max_num_hot_tbs_to_dump;
int tcg_collect_tb_stats;
uint32_t default_tbstats_flag;
@@ -276,6 +279,9 @@ const QEMULogItem qemu_log_items[] = {
{ CPU_LOG_TB_NOCHAIN, "nochain",
"do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
"complete traces" },
+ { CPU_LOG_TB_STATS, "tb_stats[[,level=(+all+jit+exec+time)][,dump_limit=<number>]]",
+ "enable collection of TBs statistics"
+ "(and dump until given a limit if in user mode).\n" },
{ 0, NULL, NULL },
};
@@ -297,6 +303,35 @@ 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")) {
+ mask |= CPU_LOG_TB_STATS;
+ default_tbstats_flag = TB_JIT_STATS | TB_EXEC_STATS | TB_JIT_TIME;
+ tcg_collect_tb_stats = TB_STATS_RUNNING;
+ } else if (tcg_collect_tb_stats == TB_STATS_RUNNING &&
+ g_str_has_prefix(*tmp, "dump_limit=")) {
+
+ max_num_hot_tbs_to_dump = atoi((*tmp) + 11);
+ } else if (tcg_collect_tb_stats == TB_STATS_RUNNING &&
+ g_str_has_prefix(*tmp, "level=")) {
+
+ default_tbstats_flag = 0;
+ char **level_parts = g_strsplit(*tmp + 6, "+", 0);
+ char **level_tmp;
+ for (level_tmp = level_parts; level_tmp && *level_tmp; level_tmp++) {
+ if (g_str_equal(*level_tmp, "jit")) {
+ default_tbstats_flag |= TB_JIT_STATS;
+ } else if (g_str_equal(*level_tmp, "exec")) {
+ default_tbstats_flag |= TB_EXEC_STATS;
+ } else if (g_str_equal(*level_tmp, "time")) {
+ default_tbstats_flag |= TB_JIT_TIME;
+ } else if (g_str_equal(*level_tmp, "all")) {
+ default_tbstats_flag |= TB_JIT_STATS | TB_EXEC_STATS | TB_JIT_TIME;
+ } else {
+ fprintf(stderr, "no option level=%s, valid options are:"
+ "all, jit, exec or/and time\n", *level_tmp);
+ exit(1);
+ }
+ }
} else {
for (item = qemu_log_items; item->mask != 0; item++) {
if (g_str_equal(*tmp, item->name)) {
Adding -d tb_stats to control TBStatistics collection: -d tb_stats[[,level=(+all+jit+exec+time)][,dump_limit=<number>]] "dump_limit" is used to limit the number of dumped TBStats in linux-user mode. [all+jit+exec+time] control the profilling level used by the TBStats. Can be used as follow: -d tb_stats -d tb_stats,level=jit+time -d tb_stats,dump_limit=15 ... Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com> --- accel/tcg/tb-stats.c | 1 + accel/tcg/translator.c | 1 + include/exec/gen-icount.h | 1 + include/exec/tb-stats.h | 15 --------------- include/qemu-common.h | 15 +++++++++++++++ include/qemu/log.h | 1 + tcg/tcg.c | 1 + util/log.c | 35 +++++++++++++++++++++++++++++++++++ 8 files changed, 55 insertions(+), 15 deletions(-)