Message ID | 20231003183058.1639121-11-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | TCG code quality tracking | expand |
On 3/10/23 20:30, Richard Henderson wrote: > From: Fei Wu <fei2.wu@intel.com> > > Enable TBStatistics collection from startup. > > 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> > [rth: Change "tb_stats_foo" to "tb_stats:foo"] > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > stubs/tb-stats.c | 16 ++++++++++++++++ > util/log.c | 36 +++++++++++++++++++++++++++++++----- > stubs/meson.build | 1 + > 3 files changed, 48 insertions(+), 5 deletions(-) > create mode 100644 stubs/tb-stats.c > > diff --git a/stubs/tb-stats.c b/stubs/tb-stats.c > new file mode 100644 > index 0000000000..ceaa1622ce > --- /dev/null > +++ b/stubs/tb-stats.c > @@ -0,0 +1,16 @@ > +/* > + * 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 "tcg/tb-stats.h" > + > +void tb_stats_init(uint32_t flags) > +{ > +} We don't need this stub anymore.
On 10/10/23 05:34, Philippe Mathieu-Daudé wrote: > On 3/10/23 20:30, Richard Henderson wrote: >> From: Fei Wu <fei2.wu@intel.com> >> >> Enable TBStatistics collection from startup. >> >> 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> >> [rth: Change "tb_stats_foo" to "tb_stats:foo"] >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> >> --- >> stubs/tb-stats.c | 16 ++++++++++++++++ >> util/log.c | 36 +++++++++++++++++++++++++++++++----- >> stubs/meson.build | 1 + >> 3 files changed, 48 insertions(+), 5 deletions(-) >> create mode 100644 stubs/tb-stats.c >> >> diff --git a/stubs/tb-stats.c b/stubs/tb-stats.c >> new file mode 100644 >> index 0000000000..ceaa1622ce >> --- /dev/null >> +++ b/stubs/tb-stats.c >> @@ -0,0 +1,16 @@ >> +/* >> + * 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 "tcg/tb-stats.h" >> + >> +void tb_stats_init(uint32_t flags) >> +{ >> +} > > We don't need this stub anymore. Certainly we do, within the tools and tests. r~
diff --git a/stubs/tb-stats.c b/stubs/tb-stats.c new file mode 100644 index 0000000000..ceaa1622ce --- /dev/null +++ b/stubs/tb-stats.c @@ -0,0 +1,16 @@ +/* + * 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 "tcg/tb-stats.h" + +void tb_stats_init(uint32_t flags) +{ +} diff --git a/util/log.c b/util/log.c index b5f08db202..0cb987fb74 100644 --- a/util/log.c +++ b/util/log.c @@ -30,6 +30,9 @@ #ifdef CONFIG_LINUX #include <sys/syscall.h> #endif +#ifdef CONFIG_TCG +#include "tcg/tb-stats.h" +#endif typedef struct RCUCloseFILE { @@ -509,22 +512,41 @@ int qemu_str_to_log_mask(const char *str, Error **errp) char **tmp; for (tmp = parts; tmp && *tmp; tmp++) { - if (g_str_equal(*tmp, "all")) { + char *t = *tmp; + + if (g_str_equal(t, "all")) { for (item = qemu_log_items; item->mask != 0; item++) { mask |= item->mask; } #ifdef CONFIG_TRACE_LOG - } else if (g_str_has_prefix(*tmp, "trace:") && (*tmp)[6] != '\0') { - trace_enable_events((*tmp) + 6); + } else if (g_str_has_prefix(t, "trace:") && t[6] != '\0') { + trace_enable_events(t + 6); mask |= LOG_TRACE; +#endif +#ifdef CONFIG_TCG + } else if (g_str_has_prefix(t, "tb_stats:") && t[9] != '\0') { + int flags = TB_STATS_NONE; + char *v = t + 9; + + if (g_str_equal(v, "all")) { + flags = TB_STATS_ALL; + } else if (g_str_equal(v, "jit")) { + flags = TB_STATS_JIT; + } else if (g_str_equal(v, "exec")) { + flags = TB_STATS_EXEC; + } else { + error_setg(errp, "Invalid -d option \"%s\"", t); + goto error; + } + tb_stats_init(flags); #endif } else { for (item = qemu_log_items; item->mask != 0; item++) { - if (g_str_equal(*tmp, item->name)) { + if (g_str_equal(t, item->name)) { goto found; } } - error_setg(errp, "Invalid -d option \"%s\"", *tmp); + error_setg(errp, "Invalid -d option \"%s\"", t); goto error; found: mask |= item->mask; @@ -546,6 +568,10 @@ void qemu_print_log_usage(FILE *f) for (item = qemu_log_items; item->mask != 0; item++) { fprintf(f, "%-15s %s\n", item->name, item->help); } +#ifdef CONFIG_TCG + fprintf(f, "tb_stats:WHICH enable translation block statistics" + " (all, exec, jit)\n"); +#endif #ifdef CONFIG_TRACE_LOG fprintf(f, "trace:PATTERN enable trace events\n"); fprintf(f, "\nUse \"-d trace:help\" to get a list of trace events.\n\n"); diff --git a/stubs/meson.build b/stubs/meson.build index ef6e39a64d..37ca25ea01 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -65,4 +65,5 @@ else stub_ss.add(files('qdev.c')) endif stub_ss.add(files('semihost-all.c')) +stub_ss.add(files('tb-stats.c')) stub_ss.add(when: 'CONFIG_VFIO_USER_SERVER', if_false: files('vfio-user-obj.c'))