Re: [PATCH v2 28/58] perf syscall-counts-by-pid: Port syscall-counts-by-pid to use python module

sashiko-bot
2026-04-23T04:14:09Z

Sashiko AI review found 1 potential issue(s):
- [Medium] The script sorts the output by syscall ID instead of syscall frequency (count), breaking the original script's behavior and contradicting the commit message.
--

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

perf syscall-counts-by-pid: Port syscall-counts-by-pid to use python module

This commit rewrites tools/perf/scripts/python/syscall-counts-by-pid.py to use
the perf python module. It improves performance by avoiding the overheads of
standard perf script execution.

> diff --git a/tools/perf/python/syscall-counts-by-pid.py b/tools/perf/python/syscall-counts-by-pid.py
> new file mode 100755
> index 0000000000000..45a98e6e8e011
> --- /dev/null
> +++ b/tools/perf/python/syscall-counts-by-pid.py
[ ... ]
> +def print_syscall_totals():
> + """Print aggregated statistics."""
[ ... ]
> + print(f"{'comm [pid]/syscalls':<40} {'count':>10}")
> + print("---------------------------------------- -----------")
> +
> + sorted_keys = sorted(syscalls.keys(), key=lambda k: (k[0], k[1], k[2]))

Does this sort order match the original script's behavior?

The commit message example shows the output sorted by syscall count descending:

perf [3886080]
write 538989
ioctl 32
sched_setaffinity 17

But the code here sorts by comm (k[0]), pid (k[1]), and then syscall ID
sc_id (k[2]) ascending.

Should this be sorting by the syscall count descending instead, so that the most
frequent syscalls appear at the top?

> + current_comm_pid = None
> + for comm, pid, sc_id in sorted_keys:

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