Changed Behavior of perf stat in linux-next
With latest linux-next (tag next-20250917) I noticed an change in behavior:
1. An undefined event now triggers a different exit code for perf stat when the event does not exist:
Before:
# perf -v perf version 6.14.0-63.fc42.s390x # perf stat -e pai_ext/NNPA_ADD/k -- true; echo exit code perf stat: $?
Performance counter stats for 'true':
<not supported> pai_ext/NNPA_ADD/k
0.001074996 seconds time elapsed
0.000051000 seconds user
0.001124000 seconds sys
exit code perf stat: 0
After:
# perf -v
perf version 6.17.0-20250918.rc6.git0.ae2d20002576.63.fc42.s390x+next # perf stat -e pai_ext/NNPA_ADD/k -- sleep; echo exit code perf stat: $? event syntax error: 'pai_ext/NNPA_ADD/k'
\___ Bad event or PMU
Unable to find PMU or event on a PMU of 'pai_ext' Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
#
exit code perf stat: 129
A invalid event now triggers a non-zero exit code indicating failure.
2. An event defined on a system but with unsupported modifier also shows different behavior:
Before:
# perf stat -e pai_ext/NNPA_ADD/k -- sleep 2; echo exit code perf stat: $?
Performance counter stats for 'sleep 2':
<not supported> pai_ext/NNPA_ADD/k
2.001368389 seconds time elapsed
0.000140000 seconds user
0.001187000 seconds sys
exit code perf stat: 0
After:
# perf stat -e pai_ext/NNPA_ADD/k -- sleep 2; echo exit code perf stat: $? Error:
Invalid event (pai_ext/NNPA_ADD/k) in per-thread mode, enable system wide with '-a'. exit code perf stat: 255
The good thing is that the process is not started and executed wheh the event does not exist.
I reckon these changes are intended and will be integrated into mainline kernel?
I am asking because of our Continuious Intergration setup runs on the linux-next and mainline linux kernel daily and has to handle both behaviors.
Thanks
Signature · 9 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294