diff mbox series

perf tools: Fix auto-complete on aarch64

Message ID 20230207035057.43394-1-yangyicong@huawei.com (mailing list archive)
State New, archived
Headers show
Series perf tools: Fix auto-complete on aarch64 | expand

Commit Message

Yicong Yang Feb. 7, 2023, 3:50 a.m. UTC
From: Yicong Yang <yangyicong@hisilicon.com>

On aarch64 CPU related events are not under event_source/devices/cpu/events,
they're under event_source/devices/armv8_pmuv3_0/events on my machine.
Using current auto-complete script will generate below error:

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

Fix this by not test /sys/bus/event_source/devices/cpu/events on aarch64
machine.

Fixes: 74cd5815d9af ("perf tool: Improve bash command line auto-complete for multiple events with comma")
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 tools/perf/perf-completion.sh | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

James Clark Feb. 8, 2023, 10:35 a.m. UTC | #1
On 07/02/2023 03:50, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> On aarch64 CPU related events are not under event_source/devices/cpu/events,
> they're under event_source/devices/armv8_pmuv3_0/events on my machine.
> Using current auto-complete script will generate below error:
> 
> [root@localhost bin]# perf stat -e
> ls: cannot access '/sys/bus/event_source/devices/cpu/events': No such file or directory
> 
> Fix this by not test /sys/bus/event_source/devices/cpu/events on aarch64
> machine.
> 
> Fixes: 74cd5815d9af ("perf tool: Improve bash command line auto-complete for multiple events with comma")
> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
> ---
>  tools/perf/perf-completion.sh | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 

Reviewed-by: James Clark <james.clark@arm.com>

> diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
> index fdf75d45efff..978249d7868c 100644
> --- a/tools/perf/perf-completion.sh
> +++ b/tools/perf/perf-completion.sh
> @@ -165,7 +165,12 @@ __perf_main ()
>  
>  		local cur1=${COMP_WORDS[COMP_CWORD]}
>  		local raw_evts=$($cmd list --raw-dump)
> -		local arr s tmp result
> +		local arr s tmp result cpu_evts
> +
> +		# 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)
> +		fi
>  
>  		if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then
>  			OLD_IFS="$IFS"
> @@ -183,9 +188,9 @@ __perf_main ()
>  				fi
>  			done
>  
> -			evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events)
> +			evts=${result}" "${cpu_evts}
>  		else
> -			evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events)
> +			evts=${raw_evts}" "${cpu_evts}
>  		fi
>  
>  		if [[ "$cur1" == , ]]; then
Arnaldo Carvalho de Melo Feb. 8, 2023, 1:39 p.m. UTC | #2
Em Wed, Feb 08, 2023 at 10:35:17AM +0000, James Clark escreveu:
> 
> 
> On 07/02/2023 03:50, Yicong Yang wrote:
> > From: Yicong Yang <yangyicong@hisilicon.com>
> > 
> > On aarch64 CPU related events are not under event_source/devices/cpu/events,
> > they're under event_source/devices/armv8_pmuv3_0/events on my machine.
> > Using current auto-complete script will generate below error:
> > 
> > [root@localhost bin]# perf stat -e
> > ls: cannot access '/sys/bus/event_source/devices/cpu/events': No such file or directory
> > 
> > Fix this by not test /sys/bus/event_source/devices/cpu/events on aarch64
> > machine.
> > 
> > Fixes: 74cd5815d9af ("perf tool: Improve bash command line auto-complete for multiple events with comma")
> > Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
> > ---
> >  tools/perf/perf-completion.sh | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> 
> Reviewed-by: James Clark <james.clark@arm.com>

Thanks, applied.

- Arnaldo

 
> > diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
> > index fdf75d45efff..978249d7868c 100644
> > --- a/tools/perf/perf-completion.sh
> > +++ b/tools/perf/perf-completion.sh
> > @@ -165,7 +165,12 @@ __perf_main ()
> >  
> >  		local cur1=${COMP_WORDS[COMP_CWORD]}
> >  		local raw_evts=$($cmd list --raw-dump)
> > -		local arr s tmp result
> > +		local arr s tmp result cpu_evts
> > +
> > +		# 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)
> > +		fi
> >  
> >  		if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then
> >  			OLD_IFS="$IFS"
> > @@ -183,9 +188,9 @@ __perf_main ()
> >  				fi
> >  			done
> >  
> > -			evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events)
> > +			evts=${result}" "${cpu_evts}
> >  		else
> > -			evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events)
> > +			evts=${raw_evts}" "${cpu_evts}
> >  		fi
> >  
> >  		if [[ "$cur1" == , ]]; then
diff mbox series

Patch

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index fdf75d45efff..978249d7868c 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -165,7 +165,12 @@  __perf_main ()
 
 		local cur1=${COMP_WORDS[COMP_CWORD]}
 		local raw_evts=$($cmd list --raw-dump)
-		local arr s tmp result
+		local arr s tmp result cpu_evts
+
+		# 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)
+		fi
 
 		if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then
 			OLD_IFS="$IFS"
@@ -183,9 +188,9 @@  __perf_main ()
 				fi
 			done
 
-			evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events)
+			evts=${result}" "${cpu_evts}
 		else
-			evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events)
+			evts=${raw_evts}" "${cpu_evts}
 		fi
 
 		if [[ "$cur1" == , ]]; then