qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	cota@braap.org,
	"Vanderson M. do Rosario" <vandersonmr2@gmail.com>,
	qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v9 03/13] accel: collecting JIT statistics
Date: Fri, 13 Dec 2019 11:51:49 +0000	[thread overview]
Message-ID: <878sngbfze.fsf@linaro.org> (raw)
In-Reply-To: <c9b4b7e3-9ba3-f40f-7ef3-eb2a34290f82@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> On 10/7/19 11:28 AM, Alex Bennée wrote:
>> @@ -1795,6 +1799,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
>>          if (flag & TB_EXEC_STATS) {
>>              tb->tb_stats->stats_enabled |= TB_EXEC_STATS;
>>          }
>> +
>> +        if (flag & TB_JIT_STATS) {
>> +            tb->tb_stats->stats_enabled |= TB_JIT_STATS;
>> +        }
>
> So, assuming that you really meant this, and not replacing as I was guessing vs
> patch 2, then this is
>
>     tb->tb_stats->stats_enabled |=
>         flag & (TB_EXEC_STATS | TB_JIT_STATS);
>
> But I still think it's weird to be wanting to modify the shared structure.
> What does that mean for concurrent code generation?

The idea was to have per translation area granularity on collecting the
stats so we didn't have to burden all areas with the overhead. Currently
this only takes effect when qemu_log_in_addr_range is in effect. However
as the run goes on we could make decisions to disable some or all stats
for stuff that doesn't come up that frequently.

However the current positioning doesn't work as we keep setting the flag
so I think we need to apply get_default_tbstats_flag() inside
tb_get_stats only when we first create the data block.

>
>> +    /*
>> +     * Collect JIT stats when enabled. We batch them all up here to
>> +     * avoid spamming the cache with atomic accesses
>> +     */
>> +    if (tb_stats_enabled(tb, TB_JIT_STATS)) {
>> +        TBStatistics *ts = tb->tb_stats;
>> +        qemu_mutex_lock(&ts->jit_stats_lock);
>> +
>> +        ts->code.num_guest_inst += prof->translation.nb_guest_insns;
>> +        ts->code.num_tcg_ops += prof->translation.nb_ops_pre_opt;
>> +        ts->code.num_tcg_ops_opt += tcg_ctx->nb_ops;
>> +        ts->code.spills += prof->translation.nb_spills;
>> +        ts->code.out_len += tb->tc.size;
>> +
>> +        ts->translations.total++;
>> +        if (phys_page2 != -1) {
>> +            ts->translations.spanning++;
>> +        }
>> +
>> +        g_ptr_array_add(ts->tbs, tb);
>> +
>> +        qemu_mutex_unlock(&ts->jit_stats_lock);
>> +    }
>
> Hmm.  So we're to interpret all of code.field as sums, the average of which can
> be obtained by dividing by translations.total.  Ok, but that should probably be
> mentioned in a comment in/near the structure definition.

OK

> What are we planning to do with the set of all tb's collected here?

Originally we kept track for the coverset calculation as we need to know
where each individual TB goes next. The code was racy so I dropped it
from the series so tracking this now is possibly redundant although it
might be useful in the future.

>
>> @@ -3125,6 +3126,7 @@ static void temp_sync
>>          case TEMP_VAL_REG:
>>              tcg_out_st(s, ts->type, ts->reg,
>>                         ts->mem_base->reg, ts->mem_offset);
>> +            s->prof.translation.nb_spills++;
>>              break;
>>  
>>          case TEMP_VAL_MEM:
>
> This is not a spill in the common compiler definition.
>
> This is "write the temp to its backing storage".  While this does happen in the
> course of spilling, the vast majority of these are because we've finished
> modifying a global temp and must now update memory.  Which is not nearly the
> same thing as "spill".
>
> A spill in the compiler definition happens in tcg_reg_alloc, right after the
> comment "We must spill something".  ;-)

OK I'll fix that.

-- 
Alex Bennée


  reply	other threads:[~2019-12-13 21:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07 15:28 [PATCH v9 00/13] TCG code quality tracking and perf integration Alex Bennée
2019-10-07 15:28 ` [PATCH v9 01/13] accel/tcg: introduce TBStatistics structure Alex Bennée
2019-10-08 12:35   ` Richard Henderson
2019-12-13 11:14     ` Alex Bennée
2019-10-07 15:28 ` [PATCH v9 02/13] accel: collecting TB execution count Alex Bennée
2019-10-08 13:10   ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 03/13] accel: collecting JIT statistics Alex Bennée
2019-10-08 13:38   ` Richard Henderson
2019-12-13 11:51     ` Alex Bennée [this message]
2019-10-07 15:28 ` [PATCH v9 04/13] accel: replacing part of CONFIG_PROFILER with TBStats Alex Bennée
2019-10-08 13:58   ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 05/13] accel: adding TB_JIT_TIME and full replacing CONFIG_PROFILER Alex Bennée
2019-10-08 15:25   ` Richard Henderson
2019-12-13 21:49     ` Alex Bennée
2019-12-16 20:34       ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 06/13] debug: add -d tb_stats to control TBStatistics collection: Alex Bennée
2019-10-08 15:34   ` Richard Henderson
2019-10-08 15:49     ` Alex Bennée
2019-10-07 15:28 ` [PATCH v9 07/13] monitor: adding tb_stats hmp command Alex Bennée
2019-10-08 15:48   ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 08/13] tb-stats: reset the tracked TBs on a tb_flush Alex Bennée
2019-10-08 18:00   ` Richard Henderson
2019-10-08 19:18     ` Alex Bennée
2019-10-07 15:28 ` [PATCH v9 09/13] Adding info [tb-list|tb] commands to HMP (WIP) Alex Bennée
2019-10-08 18:50   ` Richard Henderson
2019-10-08 19:36     ` Alex Bennée
2019-10-09  9:44   ` Dr. David Alan Gilbert
2019-10-07 15:28 ` [PATCH v9 10/13] tb-stats: dump hot TBs at the end of the execution Alex Bennée
2019-10-08 19:05   ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 11/13] accel/tcg: adding integration with linux perf Alex Bennée
2019-10-08 19:33   ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 12/13] tb-stats: adding TBStatistics info into perf dump Alex Bennée
2019-10-08 19:46   ` Richard Henderson
2019-10-07 15:28 ` [PATCH v9 13/13] configure: remove the final bits of --profiler support Alex Bennée
2019-10-08 19:39   ` Richard Henderson
2019-10-07 18:14 ` [PATCH v9 00/13] TCG code quality tracking and perf integration no-reply
2019-10-07 18:47 ` no-reply

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=878sngbfze.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=cota@braap.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).