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

sashiko-bot
2026-04-20T00:45:17Z

Sashiko AI review found 1 potential issue(s):
- [Medium] The script uses PEP 585 type hints (`dict[str, int]`) which will crash on Python versions older than 3.9.
--

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

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

This commit ports the legacy failed-syscalls.pl Perl script to a Python
script using the perf module. The new script is designed for file-based
processing of perf.data files using a class-based architecture to aggregate
failed syscalls by command name.

> diff --git a/tools/perf/python/failed-syscalls.py b/tools/perf/python/failed-syscalls.py
> new file mode 100755
> index 0000000000000..fe2a3fab0b7ad
> --- /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)

Will this type hint crash on Python versions older than 3.9?

The kernel's perf tools support Python 3.6 and newer, but built-in generics
like dict[str, int] were introduced in Python 3.9. On earlier Python versions,
evaluating this annotation raises a TypeError because the type object is not
subscriptable.

Could this be updated to use typing.Dict instead to maintain compatibility with
older supported Python versions?

> + self.for_comm = comm
> + self.session: Optional[perf.session] = None

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