Skip to contentSkip to conversation

perf tools: Avoid auto-complete failure if sysfs events are missing

PATCH New Jan Polensky 1 participant 1 message Jul 29, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf tools: Avoid auto-complete failure if sysfs events are missing

Using current auto-complete script result in the following error on systems where /sys/bus/event_source/devices/cpu/events is absent:

[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 lookup if the directory does not exist.

Replaces: [email protected]

---
Changes since v1 (Thanks Namhyung):
- Changed commit tittle.
- Removed arch specific handling and test for sysfs events.

 tools/perf/perf-completion.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/perf-completion.sh +3 -3
index 69cba3c170d5..1a91b9399f94 100644
@@ -168,11 +168,11 @@ __perf_main ()
 		local cur1=${COMP_WORDS[COMP_CWORD]}
 		local raw_evts
 		local arr s tmp result cpu_evts
+		local sysfs_events=/sys/bus/event_source/devices/cpu/events
 
 		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
-			cpu_evts=$(ls /sys/bus/event_source/devices/cpu/events)
+		if [[ -d "$sysfs_events" ]]; then
+			cpu_evts=$(ls "$sysfs_events")
 		fi
 
 		if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then

--
2.48.1