Re: [PATCH 10/14] perf test: Add thread loop test shell scripts

Carsten Haitzler
2022-07-08T16:45:28Z

On 7/8/22 11:27, Mike Leach wrote:
> Hi,
>
> On Fri, 8 Jul 2022 at 10:22, Carsten Haitzler
> <carsten.haitzler@foss.arm.com> wrote:
>>
>>
>>
>> On 7/5/22 14:53, James Clark wrote:
>>>
>>>
>>> On 01/07/2022 13:07, carsten.haitzler@foss.arm.com wrote:
>>>> From: "Carsten Haitzler (Rasterman)" <raster@rasterman.com>
>>>>
>>>> Add a script to drive the thread loop test that gathers data so
>>>> it passes a minimum bar (in this case do we get any perf context data
>>>> for every thread).
>>>>
>>>> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
>>>
>>> Hi Carsten,
>>>
>>> I checked this on N1SDP and I get failures in both threads tests. This is
>>> because it's looking for "CID=..." when in my output threads are shown as
>>> "VMID=...":
>>>
>>> Idx:628048; ID:10; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x0000AAAAE3BF0B18; Ctxt: AArch64,EL0, NS; VMID=0xa588c;
>>>
>>> I think with a change to the grep it should work.
>>
>> Errrr... I get no VMID= ... it's all
>>
>> Idx:563008; ID:12; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64
>> bit, IS0.; Addr=0x0000AAAAE4B00A60; Ctxt: AArch64,EL0, NS; CID=0x00004aff;
>>
>> are you using containers or something? because:
>>
>> if(context.updated_c)
>> {
>> oss << "CID=0x" << std::hex << std::setfill('0') <<
>> std::setw(8) << context.ctxtID << "; ";
>> }
>> if(context.updated_v)
>> {
>> oss << "VMID=0x" << std::hex << std::setfill('0') <<
>> std::setw(4) << context.VMID << "; ";
>> }
>>
>> I'm running without any containers etc. - bare metal. Haven't bothered
>> with any VM stuff.
>>
>> In OpenOCD the CID should be the the pid/thread id. It seems to not be
>> the same thing as VMID. I haven't traced this beyond here as to exactly
>> what this represents though my first reaction is "This is extra VM info
>> and not the PID/TID being looked for". OpenOCD is full of tests with log
>> dumps that produce CID and VMID:
>>
>> Idx:1676; ID:10; I_ADDR_CTXT_L_64IS0 : Address & Context, Long,
>> 64 bit, IS0.; Addr=0xFFFFFFC000096A00; Ctxt: AArch64,EL1, NS;
>> CID=0x00000000; VMID=0x0000;
>>
>> A quick git grep CID= in OpenCD will show them all. My understanding is
>> CID is the thread/process ID and thus the test/check "Do we get reported
>> data from all threads? - anything?".
>>
>> I don't think using VMID is right. The fact you are missing a CID is an
>> issue though...
>>
>
> The register used for linux TID trace is dependent on the EL of the kernel.
> EL1 => CONTEXT_IDR_EL1
> EL2 => CONTEXT_IDR_EL2.
>
> By design, the trace hardware traces CONTEXT_IDR_EL2 as the VMID packet.
>
> So, depending on your kernel build, TID can validly be traced as CID or VMID

Ahhh I haven't encountered that. So basically look for CID=xxx OR
VMID=xxx if no CID=xxx is there.

> Regards
>
> Mike
>
>>> Thanks
>>> James
>>>
>>>> ---
>>>> .../coresight/thread_loop_check_tid_10.sh | 19 +++++++++++++++++++
>>>> .../coresight/thread_loop_check_tid_2.sh | 19 +++++++++++++++++++
>>>> 2 files changed, 38 insertions(+)
>>>> create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh
>>>> create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh
>>>>
>>>> diff --git a/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh b/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh
>>>> new file mode 100755
>>>> index 000000000000..7c13636fc778
>>>> --- /dev/null
>>>> +++ b/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh
>>>> @@ -0,0 +1,19 @@
>>>> +#!/bin/sh -e
>>>> +# CoreSight / Thread Loop 10 Threads - Check TID
>>>> +
>>>> +# SPDX-License-Identifier: GPL-2.0
>>>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021
>>>> +
>>>> +TEST="thread_loop"
>>>> +. $(dirname $0)/../lib/coresight.sh
>>>> +ARGS="10 1"
>>>> +DATV="check-tid-10th"
>>>> +DATA="$DATD/perf-$TEST-$DATV.data"
>>>> +STDO="$DATD/perf-$TEST-$DATV.stdout"
>>>> +
>>>> +SHOW_TID=1 perf record -s $PERFRECOPT -o "$DATA" "$BIN" $ARGS > $STDO
>>>> +
>>>> +perf_dump_aux_tid_verify "$DATA" "$STDO"
>>>> +
>>>> +err=$?
>>>> +exit $err
>>>> diff --git a/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh b/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh
>>>> new file mode 100755
>>>> index 000000000000..a067145af43c
>>>> --- /dev/null
>>>> +++ b/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh
>>>> @@ -0,0 +1,19 @@
>>>> +#!/bin/sh -e
>>>> +# CoreSight / Thread Loop 2 Threads - Check TID
>>>> +
>>>> +# SPDX-License-Identifier: GPL-2.0
>>>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021
>>>> +
>>>> +TEST="thread_loop"
>>>> +. $(dirname $0)/../lib/coresight.sh
>>>> +ARGS="2 20"
>>>> +DATV="check-tid-2th"
>>>> +DATA="$DATD/perf-$TEST-$DATV.data"
>>>> +STDO="$DATD/perf-$TEST-$DATV.stdout"
>>>> +
>>>> +SHOW_TID=1 perf record -s $PERFRECOPT -o "$DATA" "$BIN" $ARGS > $STDO
>>>> +
>>>> +perf_dump_aux_tid_verify "$DATA" "$STDO"
>>>> +
>>>> +err=$?
>>>> +exit $err
>
>
>