From: Richard Henderson <richard.henderson@linaro.org>
To: Fei Wu <fei2.wu@intel.com>,
alex.bennee@linaro.org, qemu-devel@nongnu.org
Cc: "Vanderson M. do Rosario" <vandersonmr2@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v14 03/10] accel: collecting TB execution count
Date: Wed, 31 May 2023 17:05:05 -0700 [thread overview]
Message-ID: <fe705139-31e9-974b-4e45-2f0c653359da@linaro.org> (raw)
In-Reply-To: <20230530083526.2174430-4-fei2.wu@intel.com>
On 5/30/23 01:35, Fei Wu wrote:
> From: "Vanderson M. do Rosario" <vandersonmr2@gmail.com>
>
> If a TB has a TBS (TBStatistics) with the TB_EXEC_STATS
> enabled, then we instrument the start code of this TB
> to atomically count the number of times it is executed.
> We count both the number of "normal" executions and atomic
> executions of a TB.
>
> The execution count of the TB is stored in its respective
> TBS.
>
> All TBStatistics are created by default with the flags from
> default_tbstats_flag.
>
> [Richard Henderson created the inline gen_tb_exec_count]
>
> Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
> Message-Id: <20190829173437.5926-3-vandersonmr2@gmail.com>
> [AJB: Fix author]
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Fei Wu <fei2.wu@intel.com>
> ---
> accel/tcg/cpu-exec.c | 6 ++++++
> accel/tcg/tb-stats.c | 6 ++++++
> accel/tcg/tcg-runtime.c | 1 +
> accel/tcg/translate-all.c | 7 +++++--
> accel/tcg/translator.c | 25 +++++++++++++++++++++++++
> include/exec/gen-icount.h | 1 +
> include/exec/tb-stats-flags.h | 5 +++++
> include/exec/tb-stats.h | 13 +++++++++++++
> 8 files changed, 62 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 0e741960da..c0d8f26237 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -25,6 +25,7 @@
> #include "trace.h"
> #include "disas/disas.h"
> #include "exec/exec-all.h"
> +#include "exec/tb-stats.h"
> #include "tcg/tcg.h"
> #include "qemu/atomic.h"
> #include "qemu/rcu.h"
> @@ -562,7 +563,12 @@ void cpu_exec_step_atomic(CPUState *cpu)
> mmap_unlock();
> }
>
> + if (tb_stats_enabled(tb, TB_EXEC_STATS)) {
> + tb->tb_stats->executions.atomic++;
> + }
> +
> cpu_exec_enter(cpu);
> +
> /* execute the generated code */
> trace_exec_tb(tb, pc);
> cpu_tb_exec(cpu, tb, &tb_exit);
> diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c
> index f988bd8a31..143a52ef5c 100644
> --- a/accel/tcg/tb-stats.c
> +++ b/accel/tcg/tb-stats.c
> @@ -22,6 +22,7 @@ enum TBStatsStatus {
> };
>
> static enum TBStatsStatus tcg_collect_tb_stats;
> +static uint32_t default_tbstats_flag;
>
> void init_tb_stats_htable(void)
> {
> @@ -56,3 +57,8 @@ bool tb_stats_collection_paused(void)
> {
> return tcg_collect_tb_stats == TB_STATS_PAUSED;
> }
> +
> +uint32_t get_default_tbstats_flag(void)
> +{
> + return default_tbstats_flag;
> +}
What is the purpose of this function, instead of a global variable?
What is the meaning of 'default' in its name?
> @@ -295,6 +295,7 @@ static TBStatistics *tb_get_stats(tb_page_addr_t phys_pc, target_ulong pc,
> new_stats->pc = pc;
> new_stats->cs_base = cs_base;
> new_stats->flags = flags;
> + new_stats->stats_enabled = get_default_tbstats_flag();
Is this merely to record how we have generated a given TB?
What is the purpose of this flag over the global variable?
> diff --git a/include/exec/tb-stats-flags.h b/include/exec/tb-stats-flags.h
> index 87ee3d902e..fa71eb6f0c 100644
> --- a/include/exec/tb-stats-flags.h
> +++ b/include/exec/tb-stats-flags.h
> @@ -11,6 +11,9 @@
> #ifndef TB_STATS_FLAGS
> #define TB_STATS_FLAGS
>
> +#define TB_NOTHING (1 << 0)
> +#define TB_EXEC_STATS (1 << 1)
Why is NOTHING a non-zero flag?
> --- a/include/exec/tb-stats.h
> +++ b/include/exec/tb-stats.h
> @@ -31,6 +31,9 @@
> #include "exec/tb-stats-flags.h"
> #include "tcg/tcg.h"
>
> +#define tb_stats_enabled(tb, JIT_STATS) \
> + (tb && tb->tb_stats && (tb->tb_stats->stats_enabled & JIT_STATS))
Inline function, though again, why stats_enabled vs global variable?
r~
next prev parent reply other threads:[~2023-06-01 0:06 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 8:35 [PATCH v14 00/10] TCG code quality tracking Fei Wu
2023-05-30 8:35 ` [PATCH v14 01/10] accel/tcg: remove CONFIG_PROFILER Fei Wu
2023-05-30 8:35 ` [PATCH v14 02/10] accel/tcg: introduce TBStatistics structure Fei Wu
2023-05-31 23:59 ` Richard Henderson
2023-06-01 1:30 ` Wu, Fei
2023-06-01 2:48 ` Richard Henderson
2023-06-01 0:01 ` Richard Henderson
2023-06-01 3:19 ` Wu, Fei
2023-06-01 4:16 ` Richard Henderson
2023-06-01 5:36 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 03/10] accel: collecting TB execution count Fei Wu
2023-06-01 0:05 ` Richard Henderson [this message]
2023-06-01 5:44 ` Wu, Fei
2023-06-01 14:03 ` Richard Henderson
2023-06-02 1:54 ` Wu, Fei
2023-06-02 4:02 ` Richard Henderson
2023-05-30 8:35 ` [PATCH v14 04/10] accel/tcg: add jit stats and time to TBStatistics Fei Wu
2023-05-30 9:37 ` Markus Armbruster
2023-05-31 0:54 ` Wu, Fei
2023-06-01 1:08 ` Richard Henderson
2023-06-01 6:48 ` Wu, Fei
2023-06-01 14:10 ` Richard Henderson
2023-06-01 15:10 ` Richard Henderson
2023-05-30 8:35 ` [PATCH v14 05/10] debug: add -d tb_stats to control TBStatistics collection: Fei Wu
2023-06-01 1:18 ` Richard Henderson
2023-06-01 6:59 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 06/10] monitor: adding tb_stats hmp command Fei Wu
2023-06-01 1:23 ` Richard Henderson
2023-06-01 7:20 ` Wu, Fei
2023-06-01 14:25 ` Richard Henderson
2023-05-30 8:35 ` [PATCH v14 07/10] tb-stats: reset the tracked TBs on a tb_flush Fei Wu
2023-06-01 1:30 ` Richard Henderson
2023-06-01 7:22 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 08/10] Adding info [tb-list|tb] commands to HMP (WIP) Fei Wu
2023-06-01 2:40 ` Richard Henderson
2023-06-01 12:12 ` Wu, Fei
2023-06-06 7:30 ` Wu, Fei
2023-06-07 12:49 ` Wu, Fei
2023-06-08 7:38 ` Wu, Fei
2023-06-08 9:23 ` Peter Maydell
2023-06-08 12:06 ` Dr. David Alan Gilbert
2023-06-08 12:22 ` Peter Maydell
2023-06-09 14:32 ` Wu, Fei
2023-06-09 15:51 ` Peter Maydell
2023-06-12 1:20 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 09/10] tb-stats: dump hot TBs at the end of the execution Fei Wu
2023-05-30 8:35 ` [PATCH v14 10/10] docs: add tb-stats how to Fei Wu
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=fe705139-31e9-974b-4e45-2f0c653359da@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=fei2.wu@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--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).