Re: [Qemu-devel] [PATCH v8 06/11] Adding -d tb_stats to control TBStatistics collection:
vandersonmr writes: > -d tb_stats[[,level=(+all+jit+exec+time)][,dump_limit=]] > > "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 > --- > include/exec/gen-icount.h | 1 + > include/exec/tb-stats-flags.h | 42 +++ > include/exec/tb-stats.h | 18 +++ > include/qemu/log.h| 1 + > util/log.c| 35 + > 5 files changed, 82 insertions(+), 15 deletions(-) > create mode 100644 include/exec/tb-stats-flags.h > > diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h > index be006383b9..3987adfb0e 100644 > --- a/include/exec/gen-icount.h > +++ b/include/exec/gen-icount.h > @@ -2,6 +2,7 @@ > #define GEN_ICOUNT_H > > #include "qemu/timer.h" > +#include "tb-stats-flags.h" > > /* Helpers for instruction counting code generation. */ > > diff --git a/include/exec/tb-stats-flags.h b/include/exec/tb-stats-flags.h > new file mode 100644 > index 00..c936ac1084 > --- /dev/null > +++ b/include/exec/tb-stats-flags.h > @@ -0,0 +1,42 @@ > +/* > + * QEMU System Emulator, Code Quality Monitor System > + * > + * Copyright (c) 2019 Vanderson M. do Rosario > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. Any reason not to use GPLv2 or later here? > + */ > +#ifndef TB_STATS_FLAGS > +#define TB_STATS_FLAGS > + > +enum TBStatsStatus { > +TB_STATS_DISABLED = 0, > +TB_STATS_RUNNING, > +TB_STATS_PAUSED, > +TB_STATS_STOPPED > +}; > + > +#define TB_NOTHING(1 << 0) > +#define TB_EXEC_STATS (1 << 1) > +#define TB_JIT_STATS (1 << 2) > +#define TB_JIT_TIME (1 << 3) > + > +extern int tcg_collect_tb_stats; > +extern uint32_t default_tbstats_flag; > + > +#endif > diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h > index 0b9a6e2f72..6a53bef31b 100644 > --- a/include/exec/tb-stats.h > +++ b/include/exec/tb-stats.h > @@ -30,6 +30,8 @@ > #include "exec/tb-context.h" > #include "tcg.h" > > +#include "exec/tb-stats-flags.h" > + > #define tb_stats_enabled(tb, JIT_STATS) \ > (tb && tb->tb_stats && (tb->tb_stats->stats_enabled & JIT_STATS)) > > @@ -98,26 +100,12 @@ bool tb_stats_cmp(const void *ap, const void *bp); > > void dump_jit_exec_time_info(uint64_t dev_time); > > +void set_tbstats_flags(uint32_t flags); > 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(1 << 0) > -#define TB_EXEC_STATS (1 << 1) > -#define TB_JIT_STATS (1 << 2) > -#define TB_JIT_TIME (1 << 3) > - > -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); > diff --git a/include/qemu/log.h b/include/qemu/log.h > index b097a6cae1..a8d1997cde 100644 > --- a/include/qemu/log.h > +++ b/include/qemu/log.h > @@ -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 > diff --git a/util/log.c b/util/log.c > index 29021a4584..c3805b331b 100644 > --- a/util/log.c > +++ b/util/log.c > @@ -19,17 +19,20 @@ > > #include "qemu/osdep.h" > #include "qemu/log.h" > +#include
[Qemu-devel] [PATCH v8 06/11] Adding -d tb_stats to control TBStatistics collection:
-d tb_stats[[,level=(+all+jit+exec+time)][,dump_limit=]] "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 --- include/exec/gen-icount.h | 1 + include/exec/tb-stats-flags.h | 42 +++ include/exec/tb-stats.h | 18 +++ include/qemu/log.h| 1 + util/log.c| 35 + 5 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 include/exec/tb-stats-flags.h diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index be006383b9..3987adfb0e 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -2,6 +2,7 @@ #define GEN_ICOUNT_H #include "qemu/timer.h" +#include "tb-stats-flags.h" /* Helpers for instruction counting code generation. */ diff --git a/include/exec/tb-stats-flags.h b/include/exec/tb-stats-flags.h new file mode 100644 index 00..c936ac1084 --- /dev/null +++ b/include/exec/tb-stats-flags.h @@ -0,0 +1,42 @@ +/* + * QEMU System Emulator, Code Quality Monitor System + * + * Copyright (c) 2019 Vanderson M. do Rosario + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef TB_STATS_FLAGS +#define TB_STATS_FLAGS + +enum TBStatsStatus { +TB_STATS_DISABLED = 0, +TB_STATS_RUNNING, +TB_STATS_PAUSED, +TB_STATS_STOPPED +}; + +#define TB_NOTHING(1 << 0) +#define TB_EXEC_STATS (1 << 1) +#define TB_JIT_STATS (1 << 2) +#define TB_JIT_TIME (1 << 3) + +extern int tcg_collect_tb_stats; +extern uint32_t default_tbstats_flag; + +#endif diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 0b9a6e2f72..6a53bef31b 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -30,6 +30,8 @@ #include "exec/tb-context.h" #include "tcg.h" +#include "exec/tb-stats-flags.h" + #define tb_stats_enabled(tb, JIT_STATS) \ (tb && tb->tb_stats && (tb->tb_stats->stats_enabled & JIT_STATS)) @@ -98,26 +100,12 @@ bool tb_stats_cmp(const void *ap, const void *bp); void dump_jit_exec_time_info(uint64_t dev_time); +void set_tbstats_flags(uint32_t flags); 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(1 << 0) -#define TB_EXEC_STATS (1 << 1) -#define TB_JIT_STATS (1 << 2) -#define TB_JIT_TIME (1 << 3) - -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); diff --git a/include/qemu/log.h b/include/qemu/log.h index b097a6cae1..a8d1997cde 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -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 diff --git a/util/log.c b/util/log.c index 29021a4584..c3805b331b 100644 --- a/util/log.c +++ b/util/log.c @@ -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 "exec/tb-stats-flags.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;