Re: [PATCH V2 00/23] perf intel-pt: Better support for perf record --cpu

Leo Yan
2022-05-08T15:08:43Z

Hi Adrian,

On Fri, May 06, 2022 at 03:25:38PM +0300, Adrian Hunter wrote:
> Hi
>
> Here are V2 patches to support capturing Intel PT sideband events such as
> mmap, task, context switch, text poke etc, on every CPU even when tracing
> selected user_requested_cpus. That is, when using the perf record -C or
> --cpu option.
>
> This is needed for:
> 1. text poke: a text poke on any CPU affects all CPUs
> 2. tracing user space: a user space process can migrate between CPUs so
> mmap events that happen on a different CPU can be needed to decode a
> user_requested_cpus CPU.
>
> For example:
>
> Trace on CPU 1:
>
> perf record --kcore -C 1 -e intel_pt// &
>
> Start a task on CPU 0:
>
> taskset 0x1 testprog &
>
> Migrate it to CPU 1:
>
> taskset -p 0x2 <testprog pid>
>
> Stop tracing:
>
> kill %1
>
> Prior to these changes there will be errors decoding testprog
> in userspace because the comm and mmap events for testprog will not
> have been captured.

Thanks a lot for this patch set, I believe this is a common issue for
AUX trace (not only for Intel-PT), so I verified this patch set for both
Arm CoreSight and SPE; unfortunately both cannot see MMAP events for
migrated task. I used below commands:

# perf record -B -N --no-bpf-event -e cs_etm//u -C 0 -- taskset --cpu-list 1 uname
# perf script --no-itrace --show-mmap-events -C 1 2>/dev/null | grep MMAP | wc -l
0

# perf record -B -N --no-bpf-event -e arm_spe_0//u -C 0 -- taskset --cpu-list 1 uname
# perf script --no-itrace --show-mmap-events -C 1 2>/dev/null | grep MMAP | wc -l
0

I didn't dive into details for this patch set, so I cannot say the
failure is caused by any issue in this patch set. But it's definitely
we need to look into for Arm platforms to root cause what's the reason
it cannot record MMAP events properly when migrate tasks. Loop James
and German for this reason.

Thanks,
Leo