Skip to contentSkip to conversation

perf tools: Fix auto-complete on s390x

PATCH In review Jan Polensky 2 participants 2 messages Jul 25, 2025 – Jul 26, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Fix auto-complete on s390x

On s390x, CPU-related events are not located in event_source/devices/cpu/events. Instead, they are found in architecture specific locations depending on the hypervisor configuration:

/sys/devices/pai_crypto/events/
/sys/devices/cpum_cf_diag/events/
/sys/devices/pai_ext/events/
/sys/devices/cpum_cf/events/
/sys/devices/cpum_sf/events/

Using current auto-complete script result in the following error:

[root@localhost perf]# perf top -e
ls: cannot access '/sys/bus/event_source/devices/cpu/events': No such file or directory

Fix this by skipping the check for /sys/bus/event_source/devices/cpu/events on s390x systems.

---
 tools/perf/perf-completion.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/perf-completion.sh +2 -1
index 69cba3c170d5..8db6de98007b 100644
@@ -168,10 +168,11 @@ __perf_main ()
 		local cur1=${COMP_WORDS[COMP_CWORD]}
 		local raw_evts
 		local arr s tmp result cpu_evts
+		local arch=`uname -m`
 
 		raw_evts=$($cmd list --raw-dump hw sw cache tracepoint pmu sdt)
 		# aarch64 doesn't have /sys/bus/event_source/devices/cpu/events
-		if [[ `uname -m` != aarch64 ]]; then
+		if [[ $arch != aarch64 && $arch != s390x ]]; then
 			cpu_evts=$(ls /sys/bus/event_source/devices/cpu/events)
 		fi
 
Signature · 1 line
2.48.1
maintainer
#1 lore raw

Hello,

Quoted 28 lines · Jan Polensky

On s390x, CPU-related events are not located in event_source/devices/cpu/events. Instead, they are found in architecture specific locations depending on the hypervisor configuration:

/sys/devices/pai_crypto/events/
/sys/devices/cpum_cf_diag/events/
/sys/devices/pai_ext/events/
/sys/devices/cpum_cf/events/
/sys/devices/cpum_sf/events/

Using current auto-complete script result in the following error:

[root@localhost perf]# perf top -e
ls: cannot access '/sys/bus/event_source/devices/cpu/events': No such file or directory

Fix this by skipping the check for /sys/bus/event_source/devices/cpu/events on s390x systems.

---
 tools/perf/perf-completion.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/perf-completion.sh +0 -0
index 69cba3c170d5..8db6de98007b 100644

tools/perf/perf-completion.sh __perf_main () · line 175

Quoted 9 lines
tools/perf/perf-completion.sh +2 -1
@@ -168,10 +168,11 @@ __perf_main ()
 		local cur1=${COMP_WORDS[COMP_CWORD]}
 		local raw_evts
 		local arr s tmp result cpu_evts
+		local arch=`uname -m`
 
 		raw_evts=$($cmd list --raw-dump hw sw cache tracepoint pmu sdt)
 		# aarch64 doesn't have /sys/bus/event_source/devices/cpu/events
-		if [[ `uname -m` != aarch64 ]]; then
+		if [[ $arch != aarch64 && $arch != s390x ]]; then

I think it's better to check if the directory exists or just ignore the error message by redirecting to /dev/null.

Thanks,
Namhyung

Quoted 6 lines
tools/perf/perf-completion.sh +0 -0
 			cpu_evts=$(ls /sys/bus/event_source/devices/cpu/events)
 		fi
 
Signature · 1 line
2.48.1