Re: [PATCH v1 1/2] perf cs-etm: Validate timestamp tracing in per-thread mode

From: Leo Yan
Date: Tue Sep 05 2023 - 12:52:02 EST


On Mon, Sep 04, 2023 at 04:23:43PM +0100, James Clark wrote:
>
> On 27/08/2023 14:35, Leo Yan wrote:
> > So far, it's impossible to validate timestamp trace in Arm CoreSight when
> > the perf is in the per-thread mode. E.g. for the command:
> >
> > perf record -e cs_etm/timestamp/ --per-thread -- ls
> >
> > The command enables config 'timestamp' for 'cs_etm' event in the
> > per-thread mode. In this case, the function cs_etm_validate_config()
> > directly bails out and skips validation.
> >
> > Given profiled process can be scheduled on any CPUs in the per-thread
> > mode, this patch validates timestamp tracing for all CPUs when detect
> > the CPU map is empty.
>
> There is an edge case where the profiled process is known by the user to
> be pinned to a specific CPU, rather than possibly running on all CPUs,
> so this isn't always true.

Good point.

However, when a process is pinned to specific CPUs, we still can
dynamically change the scheduling affinity to any other CPUs by using
taskset command or calling sched_setaffinity(). From a perf session's
pespective, it is sane to validate timestamp tracing for all online
CPUs for per-thread mode.

> But I think that can be worked around by changing it to a per-cpu
> session to get around the new error. Given that this validation was only
> supposed to be best effort information and not get in the way you could
> say to not make it more restrictive.
>
> But it's quite a small edge case so either way:
>
> Reviewed-by: James Clark <james.clark@xxxxxxx>

Thanks for review!

Leo