Re: [RFC] perf arm-spe: Track task context switch for cpu-mode events

From: German Gomez
Date: Mon Nov 01 2021 - 11:37:02 EST


Hi Leo,

On 01/11/2021 15:11, Leo Yan wrote:
> Hi German,
>
> On Fri, Oct 29, 2021 at 11:51:16AM +0100, German Gomez wrote:
> [...]
> Have one concern: if cannot find the context packet, will the decoder
> drop the SPE packets until it find the first context packet? If this
> is the case, I am concern the decoder will run out for all packets
> and doesn't generate any samples if the SPE trace data doesn't contain
> any context packet.

Not really. It will only peek at the first decoded packet without
dropping it. I couldn't think of a corner case where the decoder might
miss a context packet for the first records (I also haven't seen any -1
values so far).

>> ��� if (!spe->use_ctx_pkt_for_pid &&
>> ������� (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE ||
>> �������� event->header.type == PERF_RECORD_SWITCH))
>> ����������� err = arm_spe_context_switch(spe, event, sample);
>>
>> Then we could apply patch [1] which wasn't fully merged in the end,
>> including similar `if (spe->use_ctx_pkt_for_pid)` to collect the pid/tid
>> from the context packets.
>>
>> What do you think?
> Except the above concern, the solution looks good to me.

I realized I cannot use the heap for it will not work in timeless
decoding. We can still use the queues though. By the way, is this return
statement in the arm_spe__setup_queue() function misplaced?

    if (spe->timeless_decoding)
            return 0;

Judging by the long comment in the arm_spe_run_decoder() function, it
seems like it should be placed somewhere below the call to "ret =
arm_spe_decode(...)", otherwise arm_spe_run_decoder() will begin with an
uninitialized record?

Thanks,
German

>
> Thanks,
> Leo