Re: [PATCH v1 33/58] perf check-perf-trace: Port check-perf-trace to use python module

sashiko-bot
2026-04-20T00:31:53Z

Sashiko AI review found 1 potential issue(s):
- [Medium] The script accesses a non-existent `sample_comm` attribute on `perf.sample_event` objects, causing an unconditional `AttributeError` at runtime.
--

commit c7ead2d8a935aefa471da2549e7433796e508f75
Author: Ian Rogers <irogers@google.com>

perf check-perf-trace: Port check-perf-trace to use python module

This commit adds a python script port of check-perf-trace that uses the perf
python module directly. This approach improves performance by avoiding the
creation of intermediate dictionaries for event fields.

> diff --git a/tools/perf/python/check-perf-trace.py b/tools/perf/python/check-perf-trace.py
> new file mode 100755
> index 0000000000000..a5c6081c422c2
> --- /dev/null
> +++ b/tools/perf/python/check-perf-trace.py

[ ... ]

> +def print_header(event_name: str, sample: perf.sample_event) -> None:
> + """Prints common header for events."""
> + secs = sample.sample_time // 1000000000
> + nsecs = sample.sample_time % 1000000000
> + print(f"{event_name:<20} {sample.sample_cpu:5} {secs:05}.{nsecs:09} "
> + f"{sample.sample_pid:8} {sample.sample_comm:<20} ", end=' ')

Will this raise an AttributeError when accessing sample.sample_comm?

The perf.sample_event C-extension wrapper implemented in
tools/perf/util/python.c does not appear to expose a sample_comm attribute
or property.

Because sample_comm is also not a tracepoint field, the dynamic fallback in
get_tracepoint_field() will likely fail, causing PyObject_GenericGetAttr()
to raise an exception and stop the script when processing the first event.

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260419235911.2186050-1-irogers@google.com?part=33