Re: [PATCH v5 42/58] perf powerpc-hcalls: Port powerpc-hcalls to use python module

sashiko-bot
2026-04-24T17:22:07Z

Sashiko AI review found 2 potential issue(s):
- [Medium] The script will crash unconditionally with an AttributeError because it accesses a non-existent `sample.time` attribute.
- [Medium] Tracking hypercall entry and exit using `sample.sample_pid` (Process ID / TGID) causes state corruption and dropped events for multi-threaded virtualization workloads.
--

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

perf powerpc-hcalls: Port powerpc-hcalls to use python module

This commit ports the powerpc-hcalls script to use a Python module structure.
It introduces the HCallAnalyzer class to encapsulate state and processes events
using perf.session to track hypervisor call statistics.

> diff --git a/tools/perf/python/powerpc-hcalls.py b/tools/perf/python/powerpc-hcalls.py
> new file mode 100755
> index 00000000000000..c4fa539174c9dc
> --- /dev/null
> +++ b/tools/perf/python/powerpc-hcalls.py

[ ... ]

> + def process_event(self, sample: perf.sample_event) -> None:
> + """Process a single sample event."""
> + name = str(sample.evsel)
> + pid = sample.sample_pid

Does using sample_pid correctly track concurrent hypercalls for multi-threaded
virtualization workloads?

In Linux perf, sample_pid corresponds to the Thread Group ID (Process ID).
Virtualization software like QEMU executes multiple Virtual CPUs as separate
threads within the same process, meaning all VCPUs share the same sample_pid.

If concurrent hypercalls execute on different VCPUs, wouldn't they overwrite
each other's timestamps in the d_enter dictionary?

Could this instead use sample_tid or sample_cpu to safely isolate concurrent
operations like the legacy script did?

> + time = sample.time

Will this script encounter an AttributeError when accessing the timestamp?

In the perf Python extension bindings in tools/perf/util/python.c, the event
timestamp is exposed as sample_time, not time. It appears assigning
time = sample.time will raise an exception on the first processed sample.

> + opcode = getattr(sample, "opcode", -1)

[ ... ]

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