Re: [PATCH v7 48/59] perf rw-by-file: Port rw-by-file to use python module

sashiko-bot
2026-04-25T23:09:38Z

Sashiko AI review found 1 potential issue(s):
- [Medium] The script attempts to handle raw_syscalls by checking for non-existent tracepoints 'raw_syscalls:sys_enter_read' and 'raw_syscalls:sys_enter_write'.
--

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

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

This patch ports the legacy Perl script rw-by-file.pl to a python script
using the perf module. It tracks read and write activity by file descriptor
for a given program name, aggregating bytes requested/written and total counts.

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

[ ... ]

> + def process_event(self, sample: perf.sample_event) -> None:
> + """Process events."""
> + event_name = str(sample.evsel)[6:-1]

[ ... ]

> + if comm != self.for_comm:
> + return
> +
> + if event_name in ("syscalls:sys_enter_read", "raw_syscalls:sys_enter_read"):

Are raw_syscalls:sys_enter_read and raw_syscalls:sys_enter_write actual
tracepoints? The raw_syscalls subsystem typically only defines sys_enter
and sys_exit.

If the intent was to monitor raw_syscalls:sys_enter, wouldn't this require
intercepting raw_syscalls:sys_enter, checking the syscall number in the id
field, and parsing the arguments array?

> + try:
> + fd = sample.fd
> + count = sample.count

It appears that raw_syscalls samples do not natively expose named properties
like sample.fd or sample.count.

Does this mean the script could simply check for syscalls:sys_enter_read and
syscalls:sys_enter_write instead?

> + self.reads[fd]["bytes_requested"] += count
> + self.reads[fd]["total_reads"] += 1
> + except AttributeError:
> + self.unhandled[event_name] += 1
> + elif event_name in ("syscalls:sys_enter_write", "raw_syscalls:sys_enter_write"):
> + try:
> + fd = sample.fd
> + count = sample.count
> + self.writes[fd]["bytes_written"] += count

[ ... ]

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