qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Wu, Fei" <fei2.wu@intel.com>
To: Richard Henderson <richard.henderson@linaro.org>,
	<alex.bennee@linaro.org>, <qemu-devel@nongnu.org>
Cc: "Vanderson M. do Rosario" <vandersonmr2@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v11 01/14] accel/tcg: introduce TBStatistics structure
Date: Mon, 8 May 2023 17:52:02 +0800	[thread overview]
Message-ID: <5b95440c-0bf3-bf5a-bfc7-4fb297cbb611@intel.com> (raw)
In-Reply-To: <483b6a5d-ab8a-c30f-5232-6b575a4c7bed@linaro.org>

On 5/3/2023 4:12 PM, Richard Henderson wrote:
> On 4/21/23 14:24, Fei Wu wrote:
>> From: "Vanderson M. do Rosario" <vandersonmr2@gmail.com>
>>
>> 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>
>> Message-Id: <20190829173437.5926-2-vandersonmr2@gmail.com>
>> [AJB: fix git author, review comments]
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   accel/tcg/meson.build     |  1 +
>>   accel/tcg/tb-context.h    |  1 +
>>   accel/tcg/tb-hash.h       |  7 +++++
>>   accel/tcg/tb-maint.c      | 19 ++++++++++++
>>   accel/tcg/tb-stats.c      | 58 +++++++++++++++++++++++++++++++++++++
>>   accel/tcg/translate-all.c | 43 +++++++++++++++++++++++++++
>>   include/exec/exec-all.h   |  3 ++
>>   include/exec/tb-stats.h   | 61 +++++++++++++++++++++++++++++++++++++++
>>   8 files changed, 193 insertions(+)
>>   create mode 100644 accel/tcg/tb-stats.c
>>   create mode 100644 include/exec/tb-stats.h
>>
>> diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
>> index aeb20a6ef0..9263bdde11 100644
>> --- a/accel/tcg/meson.build
>> +++ b/accel/tcg/meson.build
>> @@ -4,6 +4,7 @@ tcg_ss.add(files(
>>     'cpu-exec-common.c',
>>     'cpu-exec.c',
>>     'tb-maint.c',
>> +  'tb-stats.c',
>>     'tcg-runtime-gvec.c',
>>     'tcg-runtime.c',
>>     'translate-all.c',
>> diff --git a/accel/tcg/tb-context.h b/accel/tcg/tb-context.h
>> index cac62d9749..d7910d586b 100644
>> --- a/accel/tcg/tb-context.h
>> +++ b/accel/tcg/tb-context.h
>> @@ -35,6 +35,7 @@ struct TBContext {
>>       /* statistics */
>>       unsigned tb_flush_count;
>>       unsigned tb_phys_invalidate_count;
>> +    struct qht tb_stats;
>>   };
>>     extern TBContext tb_ctx;
>> diff --git a/accel/tcg/tb-hash.h b/accel/tcg/tb-hash.h
>> index 83dc610e4c..87d657a1c6 100644
>> --- a/accel/tcg/tb-hash.h
>> +++ b/accel/tcg/tb-hash.h
>> @@ -67,4 +67,11 @@ uint32_t tb_hash_func(tb_page_addr_t phys_pc,
>> target_ulong pc, uint32_t flags,
>>       return qemu_xxhash7(phys_pc, pc, flags, cf_mask,
>> trace_vcpu_dstate);
>>   }
>>   +static inline
>> +uint32_t tb_stats_hash_func(tb_page_addr_t phys_pc, target_ulong pc,
>> +                            uint32_t flags)
>> +{
>> +    return qemu_xxhash5(phys_pc, pc, flags);
>> +}
>> +
> 
> Why are you avoiding the hash of cs_base?
> It certainly changes the comparison for a number of guests.
> 
Just as you mentioned below, it's checked during compare. There is a
comment in TBStatistics definition.

>> +/*
>> + * This is the more or less the same compare as tb_cmp(), but the
>> + * data persists over tb_flush. We also aggregate the various
>> + * variations of cflags under one record and ignore the details of
>> + * page overlap (although we can count it).
>> + */
>> +bool tb_stats_cmp(const void *ap, const void *bp)
>> +{
>> +    const TBStatistics *a = ap;
>> +    const TBStatistics *b = bp;
>> +
>> +    return a->phys_pc == b->phys_pc &&
>> +        a->pc == b->pc &&
>> +        a->cs_base == b->cs_base &&
>> +        a->flags == b->flags;
>> +}
> 
> So, comparing cs_base, but not hashing it?
> 
Yes.

>> +void disable_collect_tb_stats(void)
>> +{
>> +    tcg_collect_tb_stats = TB_STATS_PAUSED;
>> +}
>> +
>> +void pause_collect_tb_stats(void)
>> +{
>> +    tcg_collect_tb_stats = TB_STATS_STOPPED;
>> +}
> 
> These two seem swapped.
> 
Yes, it seems so, I will update it.

Thanks,
Fei.

> 
> r~



  reply	other threads:[~2023-05-08  9:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 13:24 [PATCH v11 00/14] TCG code quality tracking Fei Wu
2023-04-21 13:24 ` [PATCH v11 01/14] accel/tcg: introduce TBStatistics structure Fei Wu
2023-05-03  8:12   ` Richard Henderson
2023-05-08  9:52     ` Wu, Fei [this message]
2023-04-21 13:24 ` [PATCH v11 02/14] accel: collecting TB execution count Fei Wu
2023-05-03  8:28   ` Richard Henderson
2023-05-08 10:02     ` Wu, Fei
2023-04-21 13:24 ` [PATCH v11 03/14] accel: collecting JIT statistics Fei Wu
2023-04-21 13:24 ` [PATCH v11 04/14] accel: replacing part of CONFIG_PROFILER with TBStats Fei Wu
2023-04-21 13:24 ` [PATCH v11 05/14] accel/tcg: move profiler dev_time to tb_stats Fei Wu
2023-04-21 13:24 ` [PATCH v11 06/14] accel/tcg: convert profiling of restore operations to TBStats Fei Wu
2023-04-21 13:24 ` [PATCH v11 07/14] accel/tcg: convert profiling of code generation " Fei Wu
2023-04-21 13:24 ` [PATCH v11 08/14] accel: adding TB_JIT_TIME and full replacing CONFIG_PROFILER Fei Wu
2023-04-21 13:24 ` [PATCH v11 09/14] debug: add -d tb_stats to control TBStatistics collection: Fei Wu
2023-04-21 13:24 ` [PATCH v11 10/14] monitor: adding tb_stats hmp command Fei Wu
2023-04-21 13:24 ` [PATCH v11 11/14] tb-stats: reset the tracked TBs on a tb_flush Fei Wu
2023-04-21 13:24 ` [PATCH v11 12/14] Adding info [tb-list|tb] commands to HMP (WIP) Fei Wu
2023-04-21 14:43   ` Wu, Fei
2023-04-21 13:24 ` [PATCH v11 13/14] tb-stats: dump hot TBs at the end of the execution Fei Wu
2023-04-21 13:24 ` [PATCH v11 14/14] configure: remove the final bits of --profiler support Fei Wu
2023-04-21 16:42 ` [PATCH v11 00/14] TCG code quality tracking Alex Bennée
2023-05-12  8:07   ` Wu, Fei
2023-05-12  8:42     ` Alex Bennée
2023-05-12  8:58       ` Wu, Fei
2023-05-12  9:29         ` Alex Bennée
2023-05-19  1:16   ` Wu, Fei
2023-05-19 22:01     ` Richard Henderson

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=5b95440c-0bf3-bf5a-bfc7-4fb297cbb611@intel.com \
    --to=fei2.wu@intel.com \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).