Re: [PATCH v5 29/58] perf futex-contention: Port futex-contention to use python module

sashiko-bot
2026-04-24T17:14:00Z

Sashiko AI review found 1 potential issue(s):
- [Medium] Unintended early return in the exception handler drops valid lock contention events if process name resolution fails.
--

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

perf futex-contention: Port futex-contention to use python module

This commit rewrites the futex-contention script to use the perf python
module directly. This avoids the overhead of perf script execution and
improves performance.

> diff --git a/tools/perf/python/futex-contention.py b/tools/perf/python/futex-contention.py
> new file mode 100755
> index 00000000000000..7c5c3d0ca60a2c
> --- /dev/null
> +++ b/tools/perf/python/futex-contention.py
[ ... ]
> @@ -0,0 +1,87 @@
[ ... ]
> +def process_event(sample: perf.sample_event) -> None:
> + """Process a single sample event."""
> + def handle_start(tid: int, uaddr: int, op: int, start_time: int) -> None:
> + if (op & FUTEX_CMD_MASK) != FUTEX_WAIT:
> + return
> + if tid not in process_names:
> + try:
> + if session:
> + process = session.process(tid)
> + if process:
> + process_names[tid] = process.comm()
> + except (TypeError, AttributeError):
> + return

Will this early return drop valid lock contention events if the process name
cannot be resolved?

It looks like if session.process(tid) or process.comm() raises a TypeError
or AttributeError, we exit handle_start() entirely and skip recording the
start time for the wait event.

Since the final reporting loop safely handles missing process names by
defaulting to unknown via process_names.get(t, 'unknown'), should this
exception handler just fall through instead of returning?

> + start_times[tid] = (uaddr, start_time)

[ ... ]

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