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

From: Leo Yan
Date: Mon Nov 01 2021 - 11:11:20 EST


Hi German,

On Fri, Oct 29, 2021 at 11:51:16AM +0100, German Gomez wrote:
> Hi Leo,
>
> The current plan is to define a global flag in the `struct arm_spe` to
> select the method of pid tracing (context pkt, or switch events):
>
>     struct arm_spe {
>        /* ... */
>        u8        use_ctx_pkt_for_pid;
>     }
>
> The method could be determined by peeking at the top element of the
> `struct auxtrace_heap` at the beginning of the perf-report. If ctx
> packets have been collected, the first one should have a context_id !=
> -1. We could then tweak this part of Namhyung patch slightly:

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.

>
>     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.

Thanks,
Leo