From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
vandersonmr <vandersonmr2@gmail.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v3 2/6] accel/tcg: Adding an optional tb execution counter
Date: Thu, 04 Jul 2019 16:22:31 +0100 [thread overview]
Message-ID: <878stdx1s8.fsf@zen.linaroharston> (raw)
In-Reply-To: <20190702210017.4275-2-vandersonmr2@gmail.com>
vandersonmr <vandersonmr2@gmail.com> writes:
> We add the option to instrument each TB to
> count the number of times it is executed and
> store this in the its TBStatistics struct.
>
> Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
> ---
> accel/tcg/tcg-runtime.c | 7 +++++++
> accel/tcg/tcg-runtime.h | 2 ++
> accel/tcg/translator.c | 1 +
> include/exec/gen-icount.h | 9 +++++++++
> 4 files changed, 19 insertions(+)
>
> diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
> index 8a1e408e31..f332eae334 100644
> --- a/accel/tcg/tcg-runtime.c
> +++ b/accel/tcg/tcg-runtime.c
> @@ -167,3 +167,10 @@ void HELPER(exit_atomic)(CPUArchState *env)
> {
> cpu_loop_exit_atomic(env_cpu(env), GETPC());
> }
> +
> +void HELPER(inc_exec_freq)(void *ptr)
> +{
> + TBStatistics *stats = (TBStatistics *) ptr;
> + g_assert(stats);
> + atomic_inc(&stats->executions.total);
> +}
> diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h
> index 4fa61b49b4..bf0b75dbe8 100644
> --- a/accel/tcg/tcg-runtime.h
> +++ b/accel/tcg/tcg-runtime.h
> @@ -28,6 +28,8 @@ DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env)
>
> DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env)
>
> +DEF_HELPER_FLAGS_1(inc_exec_freq, TCG_CALL_NO_RWG, void, ptr)
> +
> #ifdef CONFIG_SOFTMMU
>
> DEF_HELPER_FLAGS_5(atomic_cmpxchgb, TCG_CALL_NO_WG,
> diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
> index 9226a348a3..cc06070e7e 100644
> --- a/accel/tcg/translator.c
> +++ b/accel/tcg/translator.c
> @@ -54,6 +54,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
> gen_tb_start(db->tb);
> ops->tb_start(db, cpu);
> tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
> + gen_tb_exec_count(tb);
>
> while (true) {
> db->num_insns++;
> diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h
> index f7669b6841..6701ab70c0 100644
> --- a/include/exec/gen-icount.h
> +++ b/include/exec/gen-icount.h
> @@ -7,6 +7,15 @@
>
> static TCGOp *icount_start_insn;
>
> +static inline void gen_tb_exec_count(TranslationBlock *tb)
> +{
> + if (qemu_loglevel_mask(CPU_LOG_HOT_TBS) && tb->tb_stats) {
so with the changes suggested in 1/6 it would become:
if (tb->tb_stats && tb->tb_stats.stats_enabled & TB_EXEC_STATS) {
}
which would eventually make the granularity controllable on a per-TB
basis. You could even hide the above check in a inline helper in the
headers (tb-stats.h?).
> + TCGv_ptr ptr = tcg_const_ptr(tb->tb_stats);
> + gen_helper_inc_exec_freq(ptr);
> + tcg_temp_free_ptr(ptr);
> + }
> +}
> +
> static inline void gen_tb_start(TranslationBlock *tb)
> {
> TCGv_i32 count, imm;
--
Alex Bennée
next prev parent reply other threads:[~2019-07-04 15:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-02 21:00 [Qemu-devel] [PATCH v3 1/6] accel/tcg: adding structure to store TB statistics vandersonmr
2019-07-02 21:00 ` [Qemu-devel] [PATCH v3 2/6] accel/tcg: Adding an optional tb execution counter vandersonmr
2019-07-04 15:22 ` Alex Bennée [this message]
2019-07-02 21:00 ` [Qemu-devel] [PATCH v3 3/6] accel/tcg: Collecting translation/code quality measurements vandersonmr
2019-07-04 15:39 ` Alex Bennée
2019-07-02 21:00 ` [Qemu-devel] [PATCH v3 4/6] util/log: introduce dump of tbstats and -d hot_tbs:limit vandersonmr
2019-07-04 15:40 ` Alex Bennée
2019-07-04 16:34 ` Alex Bennée
2019-07-02 21:00 ` [Qemu-devel] [PATCH v3 5/6] monitor: adding info tb and tbs to monitor vandersonmr
2019-07-04 16:36 ` Alex Bennée
2019-07-05 13:54 ` Markus Armbruster
2019-07-05 14:36 ` Alex Bennée
2019-07-06 6:09 ` Markus Armbruster
2019-07-08 2:51 ` Vanderson Martins do Rosario
2019-07-08 4:49 ` Marc-André Lureau
2019-07-09 9:57 ` Dr. David Alan Gilbert
2019-07-02 21:00 ` [Qemu-devel] [PATCH v3 6/6] monitor: adding start_stats " vandersonmr
2019-07-04 16:43 ` Alex Bennée
2019-07-04 14:05 ` [Qemu-devel] [PATCH v3 1/6] accel/tcg: adding structure to store TB statistics Alex Bennée
2019-07-04 14:05 ` Alex Bennée
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=878stdx1s8.fsf@zen.linaroharston \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.