From: Richard Henderson <richard.henderson@linaro.org>
To: vandersonmr <vandersonmr2@gmail.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [Qemu-Devel][PATCH 2/3] Saving counters between tb_flush events.
Date: Sun, 16 Jun 2019 19:52:31 -0700 [thread overview]
Message-ID: <268e9e0d-847d-c51c-9e5f-d8c77b1bb553@linaro.org> (raw)
In-Reply-To: <20190614135332.12777-3-vandersonmr2@gmail.com>
On 6/14/19 6:53 AM, vandersonmr wrote:
> A new hash map was added to store the accumulated execution
> frequency of the TBs even after tb_flush events. A dump
> function was also added as a way to visualize these frequencies.
>
> Signed-off-by: vandersonmr <vandersonmr2@gmail.com>
> ---
> accel/tcg/translate-all.c | 59 +++++++++++++++++++++++++++++++++++++++
> accel/tcg/translate-all.h | 2 ++
> exec.c | 7 +++++
> include/exec/exec-all.h | 3 ++
> include/exec/tb-context.h | 9 ++++++
> include/qom/cpu.h | 2 ++
> 6 files changed, 82 insertions(+)
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index 5d1e08b169..0bc670ffad 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -1118,6 +1118,12 @@ static inline void code_gen_alloc(size_t tb_size)
> }
> }
>
> +static bool statistics_cmp(const void* ap, const void *bp) {
Watch the formatting.
> +static void do_tb_dump_exec_freq(void *p, uint32_t hash, void *userp)
> +{
> +#if TARGET_LONG_SIZE == 8
> + TBStatistics *tbs = p;
> + printf("%016lx\t%lu\n", tbs->pc, tbs->total_exec_freq);
> +#elif TARGET_LONG_SIZE == 4
> + TBStatistics *tbs = p;
> + printf("%016x\t%lu\n", tbs->pc, tbs->total_exec_freq);
> +#endif
> +}
TARGET_FMT_lx.
> +static void do_tb_read_exec_freq(void *p, uint32_t hash, void *userp)
> +{
> + TranslationBlock *tb = p;
> + TBStatistics tbscmp;
> + tbscmp.pc = tb->pc;
> + tbscmp.cs_base = tb->cs_base;
> + tbscmp.flags = tb->flags;
> +
> + TBStatistics *tbs = qht_lookup(userp, &tbscmp, hash);
> +
> + uint64_t exec_freq = tb_get_and_reset_exec_freq((TranslationBlock*) p);
> +
> + if (tbs) {
> + tbs->total_exec_freq += exec_freq;
> + } else {
> + void *existing;
> + tbs = malloc(sizeof(TBStatistics));
> + tbs->total_exec_freq = exec_freq;
> + tbs->pc = tb->pc;
> + tbs->cs_base = tb->cs_base;
> + tbs->flags = tb->flags;
> + qht_insert(userp, tbs, hash, &existing);
If you're going to ignore the result, leave the last argument NULL.
> + }
> +}
> +
> +void tb_read_exec_freq(void)
> +{
> + qht_iter(&tb_ctx.htable, do_tb_read_exec_freq, &tb_ctx.tb_statistics);
> +}
Perhaps a comment that this is called with mmap_lock held.
> +extern bool enable_freq_count;
Second declaration.
> +uint64_t tb_get_and_reset_exec_freq(TranslationBlock *tb)
> +{
> + uint64_t exec_freq = atomic_load_acquire(&tb->exec_freq);
> + atomic_store_release(&tb->exec_freq, 0);
> + return exec_freq;
> +}
What are you intending here? Either this needs a comment that it is called
with a lock held, and this does not need barriers at all (atomic_read,
atomic_set). Or this should use atomic_xchg and do the load and store in one
atomic operation.
r~
next prev parent reply other threads:[~2019-06-17 2:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 13:53 [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency vandersonmr
2019-06-14 13:53 ` [Qemu-devel] [Qemu-Devel][PATCH 1/3] Adding an optional tb execution counter vandersonmr
2019-06-17 2:28 ` Richard Henderson
2019-06-17 10:01 ` Alex Bennée
2019-06-14 13:53 ` [Qemu-devel] [Qemu-Devel][PATCH 2/3] Saving counters between tb_flush events vandersonmr
2019-06-17 2:52 ` Richard Henderson [this message]
2019-06-17 10:00 ` Alex Bennée
2019-06-14 13:53 ` [Qemu-devel] [Qemu-Devel][PATCH 3/3] Adding command line option to linux-user vandersonmr
2019-06-17 2:54 ` Richard Henderson
2019-06-17 11:30 ` Alex Bennée
2019-06-14 16:01 ` [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency no-reply
2019-06-17 10:17 ` Alex Bennée
2019-06-17 13:13 ` 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=268e9e0d-847d-c51c-9e5f-d8c77b1bb553@linaro.org \
--to=richard.henderson@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).