Re: [PATCH v6 49/59] perf rw-by-pid: Port rw-by-pid to use python module

sashiko-bot
2026-04-25T18:04:25Z

Sashiko AI review found 2 potential issue(s):
- [Medium] Commit message and code implementation contradiction regarding pylint refactoring.
- [Low] Dead code due to checking for non-existent raw_syscalls tracepoints.
--

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

perf rw-by-pid: Port rw-by-pid to use python module

This commit ports the legacy Perl script rw-by-pid.pl to a python script
using the perf module in tools/perf/python. It tracks read and write
activity by PID for all processes.

> Complications:
> - Refactored process_event to extract helper methods
> (_handle_sys_enter_read, etc.) to reduce the number of branches and
> satisfy pylint.

Is this description accurate?

The commit message mentions extracting helper methods like
_handle_sys_enter_read to satisfy pylint. However, the implementation
keeps all event processing logic within a single process_event method and
bypasses the linter with a disable comment instead.

> diff --git a/tools/perf/python/rw-by-pid.py b/tools/perf/python/rw-by-pid.py
> new file mode 100755
> index 000000000000..b206d2a575cd
> --- /dev/null
> +++ b/tools/perf/python/rw-by-pid.py

[ ... ]

> + def process_event(self, sample: perf.sample_event) -> None: # pylint: disable=too-many-branches
> + """Process events."""
> + event_name = str(sample.evsel)[6:-1]
> + pid = sample.sample_pid
> +
> + assert self.session is not None
> + try:
> + comm = self.session.find_thread(pid).comm()
> + except Exception: # pylint: disable=broad-except
> + comm = "unknown"
> +
> + if event_name in ("syscalls:sys_enter_read", "raw_syscalls:sys_enter_read"):

Are there raw_syscalls tracepoints with the syscall name appended?

The raw_syscalls subsystem typically provides generic sys_enter and sys_exit
tracepoints without the syscall name. Do these specific string checks for
raw_syscalls:sys_enter_read (and the similar exit and write variants) match
any real kernel tracepoints, or does this result in dead code?

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