Re: [PATCH v2 47/58] perf failed-syscalls: Port failed-syscalls to use python module

sashiko-bot
2026-04-23T04:19:11Z

Sashiko AI review found 2 potential issue(s):
- [Medium] The script silently ignores `raw_syscalls:sys_exit` events due to an incorrect prefix check.
- [Low] The `self.unhandled` dictionary is populated but its contents are never used.
--

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

perf failed-syscalls: Port failed-syscalls to use python module

This commit ports the legacy Perl failed-syscalls script to Python. It uses
the perf.session API to filter for sys_exit events, track failed syscalls,
and aggregate the counts per command name.

> diff --git a/tools/perf/python/failed-syscalls.py b/tools/perf/python/failed-syscalls.py
> new file mode 100755
> index 0000000000000..178c1458430a2
> --- /dev/null
> +++ b/tools/perf/python/failed-syscalls.py
[ ... ]
> +class FailedSyscalls:
> + """Tracks and displays failed system call totals."""
> + def __init__(self, comm: Optional[str] = None) -> None:
> + self.failed_syscalls: dict[str, int] = defaultdict(int)
> + self.for_comm = comm
> + self.session: Optional[perf.session] = None
> + self.unhandled: dict[str, int] = defaultdict(int)

This isn't a bug, but self.unhandled is populated during event processing but
never printed or accessed later. Is this dictionary intended to be included
in print_totals()?

[ ... ]
> + def process_event(self, sample: perf.sample_event) -> None:
> + """Process sys_exit events."""
> + event_name = str(sample.evsel)
> + if not event_name.startswith("evsel(syscalls:sys_exit_") and \
> + not event_name.startswith("evsel(raw_syscalls:sys_exit_"):
> + return

Does this incorrectly drop raw_syscalls:sys_exit events? The string
representation of the generic tracepoint is evsel(raw_syscalls:sys_exit)
which does not have a trailing underscore. Because of this, the startswith
check evaluates to false and triggers the early return.

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