From: "Alex Bennée" <alex.bennee@linaro.org>
To: vandersonmr <vandersonmr2@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v6 01/10] accel: introducing TBStatistics structure
Date: Mon, 26 Aug 2019 17:24:08 +0100 [thread overview]
Message-ID: <87h863zyhj.fsf@linaro.org> (raw)
In-Reply-To: <20190821172329.2062-2-vandersonmr2@gmail.com>
vandersonmr <vandersonmr2@gmail.com> writes:
> To store statistics for each TB, we created a TBStatistics structure
> which is linked with the TBs. TBStatistics can stay alive after
> tb_flush and be relinked to a regenerated TB. So the statistics can
> be accumulated even through flushes.
>
> The goal is to have all present and future qemu/tcg statistics and
> meta-data stored in this new structure.
>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
> ---
> accel/tcg/Makefile.objs | 2 +-
> accel/tcg/perf/Makefile.objs | 1 +
> accel/tcg/tb-stats.c | 39 ++++++++++++++++++++++++
> accel/tcg/translate-all.c | 57 ++++++++++++++++++++++++++++++++++++
> include/exec/exec-all.h | 15 +++-------
> include/exec/tb-context.h | 12 ++++++++
> include/exec/tb-hash.h | 7 +++++
> include/exec/tb-stats.h | 43 +++++++++++++++++++++++++++
> util/log.c | 2 ++
> 9 files changed, 166 insertions(+), 12 deletions(-)
> create mode 100644 accel/tcg/perf/Makefile.objs
> create mode 100644 accel/tcg/tb-stats.c
> create mode 100644 include/exec/tb-stats.h
>
> diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs
> index d381a02f34..49ffe81b5d 100644
> --- a/accel/tcg/Makefile.objs
> +++ b/accel/tcg/Makefile.objs
> @@ -2,7 +2,7 @@ obj-$(CONFIG_SOFTMMU) += tcg-all.o
> obj-$(CONFIG_SOFTMMU) += cputlb.o
> obj-y += tcg-runtime.o tcg-runtime-gvec.o
> obj-y += cpu-exec.o cpu-exec-common.o translate-all.o
> -obj-y += translator.o
> +obj-y += translator.o tb-stats.o
>
> obj-$(CONFIG_USER_ONLY) += user-exec.o
> obj-$(call lnot,$(CONFIG_SOFTMMU)) += user-exec-stub.o
> diff --git a/accel/tcg/perf/Makefile.objs b/accel/tcg/perf/Makefile.objs
> new file mode 100644
> index 0000000000..f82fba35e5
> --- /dev/null
> +++ b/accel/tcg/perf/Makefile.objs
> @@ -0,0 +1 @@
> +obj-y += jitdump.o
> diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c
> new file mode 100644
> index 0000000000..02844717cb
> --- /dev/null
> +++ b/accel/tcg/tb-stats.c
> @@ -0,0 +1,39 @@
I should have picked up on this last time but you need a copyright
header for you new files.
> +#include "qemu/osdep.h"
> +
> +#include "disas/disas.h"
> +
> +#include "exec/tb-stats.h"
> +
<snip>
> diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h
> new file mode 100644
> index 0000000000..cc8f8a6ce6
> --- /dev/null
> +++ b/include/exec/tb-stats.h
> @@ -0,0 +1,43 @@
And a copyright header here as well.
> +#ifndef TB_STATS_H
> +
> +#define TB_STATS_H
> +
> +#include "exec/cpu-common.h"
> +#include "exec/tb-context.h"
> +#include "tcg.h"
> +
> +typedef struct TBStatistics TBStatistics;
> +
> +/*
> + * This struct stores statistics such as execution count of the
> + * TranslationBlocks. Each sets of TBs for a given phys_pc/pc/flags
> + * has its own TBStatistics which will persist over tb_flush.
> + *
> + * We include additional counters to track number of translations as
> + * well as variants for compile flags.
> + */
> +struct TBStatistics {
> + tb_page_addr_t phys_pc;
> + target_ulong pc;
> + uint32_t flags;
> + /* cs_base isn't included in the hash but we do check for matches */
> + target_ulong cs_base;
> + /* current TB linked to this TBStatistics */
> + TranslationBlock *tb;
> +};
> +
> +bool tb_stats_cmp(const void *ap, const void *bp);
> +
> +void init_tb_stats_htable_if_not(void);
> +
> +/* TBStatistic collection controls */
> +enum TBStatsStatus { TB_STATS_RUNNING, TB_STATS_PAUSED, TB_STATS_STOPPED };
> +extern int tcg_collect_tb_stats;
> +
> +void enable_collect_tb_stats(void);
> +void disable_collect_tb_stats(void);
> +void pause_collect_tb_stats(void);
> +bool tb_stats_collection_enabled(void);
> +bool tb_stats_collection_paused(void);
> +
> +#endif
> diff --git a/util/log.c b/util/log.c
> index 1d1b33f7d9..393a17115b 100644
> --- a/util/log.c
> +++ b/util/log.c
> @@ -31,6 +31,8 @@ int qemu_loglevel;
> static int log_append = 0;
> static GArray *debug_regions;
>
> +int tcg_collect_tb_stats;
> +
> /* Return the number of characters emitted. */
> int qemu_log(const char *fmt, ...)
> {
--
Alex Bennée
next prev parent reply other threads:[~2019-08-26 16:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 17:23 [Qemu-devel] [PATCH v6 00/10] Measure Tiny Code Generation Quality vandersonmr
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 01/10] accel: introducing TBStatistics structure vandersonmr
2019-08-26 16:24 ` Alex Bennée [this message]
2019-08-26 16:25 ` Alex Bennée
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 02/10] accel: collecting TB execution count vandersonmr
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 03/10] accel: collecting JIT statistics vandersonmr
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 04/10] accel: replacing part of CONFIG_PROFILER with TBStats vandersonmr
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 05/10] accel: adding TB_JIT_TIME and full replacing CONFIG_PROFILER vandersonmr
2019-08-27 13:11 ` Alex Bennée
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 06/10] log: adding -d tb_stats to control tbstats vandersonmr
2019-08-27 13:31 ` Alex Bennée
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 07/10] monitor: adding tb_stats hmp command vandersonmr
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 08/10] Adding info [tb-list|tb|coverset] commands to HMP vandersonmr
2019-08-22 9:52 ` Dr. David Alan Gilbert
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 09/10] monitor: adding new info cfg command vandersonmr
2019-08-22 10:00 ` Dr. David Alan Gilbert
2019-08-21 17:23 ` [Qemu-devel] [PATCH v6 10/10] linux-user: dumping hot TBs at the end of the execution vandersonmr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h863zyhj.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=vandersonmr2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).