All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Polensky <japo@linux.ibm.com>
To: adrian.hunter@intel.com, irogers@google.com, namhyung@kernel.org,
	tmricht@linux.ibm.com (Thomas Richter)
Cc: linux-perf-users@vger.kernel.org
Subject: [PATCH v2 1/1] perf tools: Avoid auto-complete failure if sysfs events are missing
Date: Tue, 29 Jul 2025 13:03:08 +0200	[thread overview]
Message-ID: <20250729110308.3675428-1-japo@linux.ibm.com> (raw)

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: aIRnJDMRNO8olMdD@google.com
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
---
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(-)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index 69cba3c170d5..1a91b9399f94 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -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


                 reply	other threads:[~2025-07-29 11:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250729110308.3675428-1-japo@linux.ibm.com \
    --to=japo@linux.ibm.com \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.