qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Laurent Desnogues <laurent.desnogues@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH v5 17/17] target/arm: Rely on hflags correct in cpu_get_tb_cpu_state
Date: Thu, 05 Sep 2019 16:50:20 +0100	[thread overview]
Message-ID: <874l1q91z7.fsf@linaro.org> (raw)
In-Reply-To: <CABoDooPis6VR-3zw6EcCerwmTfZ_c2gqbCtVDSnpB30q-Oh01A@mail.gmail.com>


Laurent Desnogues <laurent.desnogues@gmail.com> writes:

> On Thu, Sep 5, 2019 at 5:24 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>>
>> Richard Henderson <richard.henderson@linaro.org> writes:
>>
>> > This is the payoff.
>> >
>> > From perf record -g data of ubuntu 18 boot and shutdown:
>> >
>> > BEFORE:
>> >
>> > -   23.02%     2.82%  qemu-system-aar  [.] helper_lookup_tb_ptr
>> >    - 20.22% helper_lookup_tb_ptr
>> >       + 10.05% tb_htable_lookup
>> >       - 9.13% cpu_get_tb_cpu_state
>> >            3.20% aa64_va_parameters_both
>> >            0.55% fp_exception_el
>> >
>> > -   11.66%     4.74%  qemu-system-aar  [.] cpu_get_tb_cpu_state
>> >    - 6.96% cpu_get_tb_cpu_state
>> >         3.63% aa64_va_parameters_both
>> >         0.60% fp_exception_el
>> >         0.53% sve_exception_el
>> >
>> > AFTER:
>> >
>> > -   16.40%     3.40%  qemu-system-aar  [.] helper_lookup_tb_ptr
>> >    - 13.03% helper_lookup_tb_ptr
>> >       + 11.19% tb_htable_lookup
>> >         0.55% cpu_get_tb_cpu_state
>> >
>> >      0.98%     0.71%  qemu-system-aar  [.] cpu_get_tb_cpu_state
>> >
>> >      0.87%     0.24%  qemu-system-aar  [.] rebuild_hflags_a64
>> >
>> > Before, helper_lookup_tb_ptr is the second hottest function in the
>> > application, consuming almost a quarter of the runtime.  Within the
>> > entire execution, cpu_get_tb_cpu_state consumes about 12%.
>> >
>> > After, helper_lookup_tb_ptr has dropped to the fourth hottest function,
>> > with consumption dropping to a sixth of the runtime.  Within the
>> > entire execution, cpu_get_tb_cpu_state has dropped below 1%, and the
>> > supporting function to rebuild hflags also consumes about 1%.
>> >
>> > Assertions are retained for --enable-debug-tcg.
>> >
>> > Tested-by: Alex Bennée <alex.bennee@linaro.org>
>>
>> Hmm something must have been missed for M-profile because:
>>
>>   make run-tcg-tests-arm-softmmu V=1
>>
>> Leads to:
>>
>>   timeout 15  /home/alex/lsrc/qemu.git/builds/all.debug/arm-softmmu/qemu-system-arm -monitor none -display none -chardev file,path=test-armv6m-undef.out,id=output -semihosting -M microbit -kernel test-armv6m-undef
>>   qemu: fatal: Lockup: can't escalate 3 to HardFault (current priority -1)
>>
>>   R00=00000000 R01=00000000 R02=00000000 R03=00000000
>>   R04=00000000 R05=00000000 R06=00000000 R07=00000000
>>   R08=00000000 R09=00000000 R10=00000000 R11=00000000
>>   R12=00000000 R13=20003fe0 R14=fffffff9 R15=000000c0
>>   XPSR=41000003 -Z-- T handler
>>   FPSCR: 00000000
>>   timeout: the monitored command dumped core
>>
>> But annoyingly not shown up by the debug-tcg verification. The commit
>> before works fine.
>
> There's a typo in the patch:  that should not be CONFIG_TCG_DEBUG but
> CONFIG_DEBUG_TCG.  With this you should see the assert fire.

Indeed:

  cpu_get_tb_cpu_state: cache 110000c0 <> 312000c0

I wish there was an assert form that would handily print out the
difference between the two values. I wonder if glib has one...

>
> I let Richard know that there's an issue with the handling of CPSR E
> flag (BE_DATA in hflags).  I don't know if that applies to your test.
>
> Thanks,
>
> Laurent
>
>> > Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> > ---
>> > v2: Retain asserts for future debugging.
>> > ---
>> >  target/arm/helper.c | 9 ++++++---
>> >  1 file changed, 6 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/target/arm/helper.c b/target/arm/helper.c
>> > index d1bf71a260..5e4f996882 100644
>> > --- a/target/arm/helper.c
>> > +++ b/target/arm/helper.c
>> > @@ -11211,12 +11211,15 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el)
>> >  void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
>> >                            target_ulong *cs_base, uint32_t *pflags)
>> >  {
>> > -    uint32_t flags, pstate_for_ss;
>> > +    uint32_t flags = env->hflags;
>> > +    uint32_t pstate_for_ss;
>> >
>> >      *cs_base = 0;
>> > -    flags = rebuild_hflags_internal(env);
>> > +#ifdef CONFIG_TCG_DEBUG
>> > +    assert(flags == rebuild_hflags_internal(env));
>> > +#endif
>> >
>> > -    if (is_a64(env)) {
>> > +    if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) {
>> >          *pc = env->pc;
>> >          if (cpu_isar_feature(aa64_bti, env_archcpu(env))) {
>> >              flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype);
>>
>>
>> --
>> Alex Bennée
>>


--
Alex Bennée


  reply	other threads:[~2019-09-05 15:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 21:07 [Qemu-devel] [PATCH v5 00/17] target/arm: Reduce overhead of cpu_get_tb_cpu_state Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 01/17] target/arm: Split out rebuild_hflags_common Richard Henderson
2019-09-05 13:58   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 02/17] target/arm: Split out rebuild_hflags_a64 Richard Henderson
2019-09-05 15:28   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2019-09-06  3:26     ` Richard Henderson
2019-09-06 15:52       ` Alex Bennée
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 03/17] target/arm: Split out rebuild_hflags_common_32 Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 04/17] target/arm: Split arm_cpu_data_is_big_endian Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 05/17] target/arm: Split out rebuild_hflags_m32 Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 06/17] target/arm: Reduce tests vs M-profile in cpu_get_tb_cpu_state Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 07/17] target/arm: Split out rebuild_hflags_a32 Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 08/17] target/arm: Split out rebuild_hflags_aprofile Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 09/17] target/arm: Hoist XSCALE_CPAR, VECLEN, VECSTRIDE in cpu_get_tb_cpu_state Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 10/17] target/arm: Simplify set of PSTATE_SS " Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 11/17] target/arm: Hoist computation of TBFLAG_A32.VFPEN Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 12/17] target/arm: Add arm_rebuild_hflags Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 13/17] target/arm: Split out arm_mmu_idx_el Richard Henderson
2019-09-06  7:12   ` Philippe Mathieu-Daudé
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 14/17] target/arm: Hoist store to cs_base in cpu_get_tb_cpu_state Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 15/17] target/arm: Add HELPER(rebuild_hflags_{a32, a64, m32}) Richard Henderson
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 16/17] target/arm: Rebuild hflags at EL changes and MSR writes Richard Henderson
2019-09-05 13:53   ` Alex Bennée
2019-08-20 21:07 ` [Qemu-devel] [PATCH v5 17/17] target/arm: Rely on hflags correct in cpu_get_tb_cpu_state Richard Henderson
2019-09-05 15:23   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2019-09-05 15:40     ` Laurent Desnogues
2019-09-05 15:50       ` Alex Bennée [this message]
2019-09-06  3:02         ` Richard Henderson
2019-08-20 23:54 ` [Qemu-devel] [PATCH v5 00/17] target/arm: Reduce overhead of cpu_get_tb_cpu_state Richard Henderson
2019-09-04 10:48   ` Peter Maydell
2019-09-04 17:26     ` 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=874l1q91z7.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=laurent.desnogues@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).