Fix for shellcheck issues with latest scripts in tests/shell
PATCH 1/3 perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Athira RajeevRunning shellcheck on tests/shell/test_arm_coresight.sh throws below warnings:
In tests/shell/test_arm_coresight.sh line 15:
cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.
In tests/shell/test_arm_coresight.sh line 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commit bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")"
Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/test_arm_coresight.sh +2 -2
@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete" else echo "etm"
Signature · 1 line
2.31.1
cover Fix for shellcheck issues with latest scripts in tests/shell
shellcheck was run on perf tool shell scripts as a pre-requisite to include a build option for shellcheck discussed here:
https://www.spinics.net/lists/linux-perf-users/msg25553.html
And fixes were added for the coding/formatting issues in two patchsets:
https://lore.kernel.org/linux-perf-users/[email protected]/
https://lore.kernel.org/linux-perf-users/[email protected]/
Three additional issues were observed and fixes are part of:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-next
With recent commits in perf, other three issues are observed. shellcheck version: 0.6.0
With this patchset:
for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; done echo $?
0
The changes are with recent commits ( which is mentioned in each patch) for ock_contention, record_sideband and test_arm_coresight testcases. The changes are made on top of:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-next
Athira Rajeev (3):
perf tests test_arm_coresight: Fix the shellcheck warning in latest
test_arm_coresight.sh
tools/perf/tests Ignore the shellcheck SC2046 warning in
lock_contentio
tools/perf/tests: Fix shellcheck warning in record_sideband.sh test
tools/perf/tests/shell/lock_contention.sh | 1 + tools/perf/tests/shell/record_sideband.sh | 2 +- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.31.1
PATCH 2/3 tools/perf/tests Ignore the shellcheck SC2046 warning in lock_contentio
Running shellcheck on lock_contention.sh generates below warning
In tests/shell/lock_contention.sh line 36:
if [ nproc -lt 4 ]; then
^-----^ SC2046: Quote this to prevent word splitting.
Here since nproc will generate a single word output and there is no possibility of word splitting, this warning can be ignored. Use exception for this with "disable" option in shellcheck. This warning is observed after commit:
"commit 29441ab3a30a ("perf test lock_contention.sh: Skip test if not enough CPUs")"
--- tools/perf/tests/shell/lock_contention.sh | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/shell/lock_contention.sh +1 -0
@@ -33,6 +33,7 @@ check() { exit fi + # shellcheck disable=SC2046 if [ `nproc` -lt 4 ]; then echo "[Skip] Low number of CPUs (`nproc`), lock event cannot be triggered certainly" err=2
Signature · 1 line
2.31.1
PATCH 3/3 tools/perf/tests: Fix shellcheck warning in record_sideband.sh test
In reply to Athira RajeevRunning shellcheck on record_sideband.sh throws below warning:
In tests/shell/record_sideband.sh line 25:
if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null
^--^ SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).This shows shellcheck warning SC2069 where the redirection order needs to be fixed. Use { cmd > file; } 2>&1 to fix the redirection of perf record output
--- tools/perf/tests/shell/record_sideband.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/record_sideband.sh +1 -1
@@ -22,7 +22,7 @@ trap trap_cleanup EXIT TERM INT can_cpu_wide() { - if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null + if ! { perf record -o ${perfdata} -BN --no-bpf-event -C $1 true > /dev/null; } 2>&1 then echo "record sideband test [Skipped cannot record cpu$1]" err=2
Signature · 1 line
2.31.1
Patchset looks fine to me.
thanks,
Kajol Jain
Quoted 38 lines · Athira Rajeev
shellcheck was run on perf tool shell scripts as a pre-requisite to include a build option for shellcheck discussed here:
https://www.spinics.net/lists/linux-perf-users/msg25553.htmlAnd fixes were added for the coding/formatting issues in two patchsets:
https://lore.kernel.org/linux-perf-users/[email protected]/
https://lore.kernel.org/linux-perf-users/[email protected]/Three additional issues were observed and fixes are part of:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-nextWith recent commits in perf, other three issues are observed. shellcheck version: 0.6.0
With this patchset:
for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; done echo $?
0The changes are with recent commits ( which is mentioned in each patch) for
ock_contention,record_sidebandandtest_arm_coresighttestcases. The changes are made on top of:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-nextAthira Rajeev (3):
perf teststest_arm_coresight: Fix the shellcheck warning in latest
test_arm_coresight.sh
tools/perf/testsIgnore the shellcheck SC2046 warning in
lock_contentio
tools/perf/tests: Fix shellcheck warning inrecord_sideband.shtesttools/perf/tests/shell/lock_contention.sh | 1 + tools/perf/tests/shell/record_sideband.sh | 2 +- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-)
Namhyung Kim
maintainerRe: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Athira RajeevQuoted 12 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined
Quoted 8 lines
This warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>
You'd better add Coresight folks on this. Maybe this file was missing in the MAINTAINERS file.
Thanks,
Namhyung
Quoted 26 lines
--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +2
-3@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete" else echo "etm" --2.31.1
Namhyung Kim
maintainerRe: [PATCH 3/3] tools/perf/tests: Fix shellcheck warning in record_sideband.sh test
In reply to Athira RajeevQuoted 23 lines · Athira Rajeev
Running shellcheck on
record_sideband.shthrows below warning:In tests/shell/record_sideband.sh line 25: if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null ^--^ SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).This shows shellcheck warning SC2069 where the redirection order needs to be fixed. Use { cmd > file; } 2>&1 to fix the redirection of perf record output
Fixes 23b97c7ee963 ("perf test: Add test case for record sideband events")Signed-off-by Athira Rajeev <[email protected]>--- tools/perf/tests/shell/record_sideband.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/tests/shell/record_sideband.sh +0
-0
tools/perf/tests/shell/record_sideband.sh trap trap_cleanup EXIT TERM INT · line 25
Quoted 5 lines
tools/perf/tests/shell/record_sideband.sh +1
-1@@ -22,7 +22,7 @@ trap trap_cleanup EXIT TERM INT can_cpu_wide() { - if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null + if ! { perf record -o ${perfdata} -BN --no-bpf-event -C $1 true > /dev/null; } 2>&1
I think we usually go without braces.
Thanks,
Namhyung
Quoted 6 lines
tools/perf/tests/shell/record_sideband.sh +0
-1then echo "record sideband test [Skipped cannot record cpu$1]" err=2 --2.31.1
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Namhyung KimQuoted 20 lines · Namhyung Kim
Quoted 18 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Quoted 9 lines
Quoted 2 lines
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>You'd better add Coresight folks on this. Maybe this file was missing in the
MAINTAINERSfile.Thanks,
Namhyung
get_maintainer already does a pretty good job with the defaults, but maybe I can try to add all the Coresight Perf stuff in the maintainers file.
Quoted 27 lines
Quoted 27 lines
--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +2
-3@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete" else echo "etm" --2.31.1
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Athira RajeevQuoted 32 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In tests/shell/test_arm_coresight.sh line 15: cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) ^--^ SC2061: Quote the parameter to -name so the shell won't interpret it. In tests/shell/test_arm_coresight.sh line 20: if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +0
-1@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit)
tools/perf/tests/shell/test_arm_coresight.sh line 23
Quoted 10 lines
tools/perf/tests/shell/test_arm_coresight.sh +2
-1+ cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete" else echo "etm"
Re: [PATCH 3/3] tools/perf/tests: Fix shellcheck warning in record_sideband.sh test
In reply to Namhyung KimQuoted 30 lines · Namhyung Kim
Quoted 24 lines · Athira Rajeev
Running shellcheck on
record_sideband.shthrows below warning:In tests/shell/record_sideband.sh line 25: if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null ^--^ SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).This shows shellcheck warning SC2069 where the redirection order needs to be fixed. Use { cmd > file; } 2>&1 to fix the redirection of perf record output
Fixes 23b97c7ee963 ("perf test: Add test case for record sideband events")Signed-off-by Athira Rajeev <[email protected]>---
tools/perf/tests/shell/record_sideband.sh| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/tests/shell/record_sideband.sh +0
-0@@ -22,7 +22,7 @@ trap trap_cleanup EXIT TERM INT
Quoted 6 lines
tools/perf/tests/shell/record_sideband.sh trap trap_cleanup EXIT TERM INT · line 25
Quoted 4 lines
tools/perf/tests/shell/record_sideband.sh +1
-1can_cpu_wide() { - if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null + if ! { perf record -o ${perfdata} -BN --no-bpf-event -C $1 true > /dev/null; } 2>&1I think we usually go without braces.
Hi Namhyung
Thanks for reviving.I will fix this in V2
Thanks
Athira
Quoted 10 lines
Thanks,
NamhyungQuoted 5 lines
tools/perf/tests/shell/record_sideband.sh +0
-1then echo "record sideband test [Skipped cannot record cpu$1]" err=2 --2.31.1
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Namhyung KimQuoted 14 lines · Namhyung Kim
Quoted 12 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined
Quoted 8 lines
Quoted 8 lines
This warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>
Thanks for the fix.
Nothing to do with this patch, but I am wondering if the original patch is over engineered and may not be future proof.
e.g.,
cs_etm_dev_name() {
+ cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit)
Right there you got the device name and we can easily deduce the name of the "ETM" node.
e.g,:
etm=$(basename $(readlink cs_etm_path) | sed "s/[0-9]\+$//")
And practically, nobody prevents an ETE mixed with an ETM on a "hybrid" system (hopefully, no one builds it ;-))
Also, instead of hardcoding "ete" and "etm" prefixes from the arch part, we should simply use the cpu nodes from :
/sys/bus/event_source/devices/cs_etm/
e.g.,
arm_cs_etm_traverse_path_test() {
# Iterate for every ETM device
for c in /sys/bus/event_source/devices/cs_etm/cpu*; do
# Read the link to be on the safer side dev=readlink $c
# Find the ETM device belonging to which CPU cpu=cat $dev/cpu
# Use depth-first search (DFS) to iterate outputs arm_cs_iterate_devices $dev $cpu
done;
}
Quoted 3 lines
You'd better add Coresight folks on this. Maybe this file was missing in the
MAINTAINERSfile.
And the original author of the commit, that introduced the issue too.
Suzuki
Quoted 31 lines
Thanks,
NamhyungQuoted 26 lines
--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +2
-3@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete" else echo "etm" --2.31.1
RE: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Athira RajeevFrom: Athira Rajeev
Quoted 31 lines
Sent: 29 September 2023 05:12
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In tests/shell/test_arm_coresight.sh line 15: cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) ^--^ SC2061: Quote the parameter to -name so the shell won't interpret it. In tests/shell/test_arm_coresight.sh line 20: if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +0
-0
tools/perf/tests/shell/test_arm_coresight.sh line 15
Quoted 5 lines
tools/perf/tests/shell/test_arm_coresight.sh +1
-1@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit)
Isn't the intention to get the shell to expand "cpu* ? So quoting it completely breaks the script.
tools/perf/tests/shell/test_arm_coresight.sh line 20
Quoted 6 lines
tools/perf/tests/shell/test_arm_coresight.sh +1
-1trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
The only issue I see there is that $archhver could be in "". IIRC test is required to parse the 5 part expression "a op b -a c op d" in the 'expected' manner even if any of a/b/c/d look like operators. In any case '(' and ')' can be used to force the ordering. Or, more usually, prepend an x as in:
if [ "x$archhver" = x5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
David
Quoted 5 lines
tools/perf/tests/shell/test_arm_coresight.sh +0
-1echo "ete" else echo "etm" --2.31.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to James ClarkQuoted 44 lines · James Clark
Quoted 37 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>---
tools/perf/tests/shell/test_arm_coresight.sh| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +0
-0@@ -12,12 +12,12 @@glb_err=0
cs_etm_dev_name(){
- cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) &0xf))
archpart=$(($trcdevarch &0xfff))
Quoted 8 lines
Quoted 5 lines
- if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "
0xA13" ] ; then
+ if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete"
else
echo "etm"Reviewed-by James Clark <[email protected]>
Thanks James for checking
Athira
RE: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to David LaightFrom: David Laight
Quoted 1 line
Sent: 05 October 2023 11:16
...
Quoted 5 lines
tools/perf/tests/shell/test_arm_coresight.sh line 15
Quoted 2 lines
tools/perf/tests/shell/test_arm_coresight.sh +1
-1- cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit)Isn't the intention to get the shell to expand "cpu* ? So quoting it completely breaks the script.
Complete brain-fade :-(
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
Quoted 14 lines · David Laight
From: David Laight
Quoted 1 line
Sent: 05 October 2023 11:16
...
Quoted 5 lines
Quoted 2 lines
- cs_etm_path=$(find
/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name 'cpu*' -print -quit)Isn't the intention to get the shell to expand "cpu* ? So quoting it completely breaks the script.
Complete brain-fade :-(
Hi David,
Yeah, quoting it also will expand
Thanks
Athira
Quoted 5 lines
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Suzuki K PouloseQuoted 70 lines · Suzuki K Poulose
Quoted 14 lines · Namhyung Kim
Quoted 12 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedQuoted 8 lines
Quoted 8 lines
This warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>Thanks for the fix.
Nothing to do with this patch, but I am wondering if the original patch is over engineered and may not be future proof.
e.g.,
cs_etm_dev_name(){
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)Right there you got the device name and we can easily deduce the name of the "ETM" node.
e.g,:
etm=$(basename $(readlinkcs_etm_path) | sed "s/[0-9]\+$//")And practically, nobody prevents an ETE mixed with an ETM on a "hybrid" system (hopefully, no one builds it ;-))
Also, instead of hardcoding "ete" and "etm" prefixes from the arch part, we should simply use the cpu nodes from :
/sys/bus/event_source/devices/cs_etm/e.g.,
arm_cs_etm_traverse_path_test(){
# Iterate for every ETM device
for c in/sys/bus/event_source/devices/cs_etm/cpu*; do # Read the link to be on the safer side dev=readlink $c# Find the ETM device belonging to which CPU
cpu=cat $dev/cpu# Use depth-first search (DFS) to iterate outputs
arm_cs_iterate_devices$dev $cpu
done;
}
Quoted 6 lines
Quoted 2 lines
You'd better add Coresight folks on this. Maybe this file was missing in the
MAINTAINERSfile.And the original author of the commit, that introduced the issue too.
Suzuki
Hi All,
Thanks for the discussion and feedbacks.
This patch fixes the shellcheck warning introduced in function "cs_etm_dev_name". But with the changes that Suzuki suggested, we won't need the function "cs_etm_dev_name" since the code will use "/sys/bus/event_source/devices/cs_etm/" . In that case, can I drop this patch for now from this series ?
Thanks
Athira
Quoted 28 lines
Quoted 28 lines
Thanks,
NamhyungQuoted 25 lines
--- tools/perf/tests/shell/test_arm_coresight.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +2
-3@@ -12,12 +12,12 @@ glb_err=0 cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) + cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) & 0xf)) archpart=$(($trcdevarch & 0xfff)) - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then + if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete" else echo "etm" --2.31.1
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
Hi,
Quoted 8 lines · Athira Rajeev
Quoted 8 lines · Suzuki K Poulose
Quoted 3 lines · Namhyung Kim
Quoted 1 line · Athira Rajeev
...
Quoted 45 lines
Quoted 45 lines
Thanks for the fix.
Nothing to do with this patch, but I am wondering if the original patch is over engineered and may not be future proof.
e.g.,
cs_etm_dev_name(){
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)Right there you got the device name and we can easily deduce the name of the "ETM" node.
e.g,:
etm=$(basename $(readlinkcs_etm_path) | sed "s/[0-9]\+$//")And practically, nobody prevents an ETE mixed with an ETM on a "hybrid" system (hopefully, no one builds it ;-))
Also, instead of hardcoding "ete" and "etm" prefixes from the arch part, we should simply use the cpu nodes from :
/sys/bus/event_source/devices/cs_etm/e.g.,
arm_cs_etm_traverse_path_test(){
# Iterate for every ETM device
for c in/sys/bus/event_source/devices/cs_etm/cpu*; do # Read the link to be on the safer side dev=readlink $c# Find the ETM device belonging to which CPU
cpu=cat $dev/cpu# Use depth-first search (DFS) to iterate outputs
arm_cs_iterate_devices$dev $cpu
done;
}Quoted 2 lines
You'd better add Coresight folks on this. Maybe this file was missing in the
MAINTAINERSfile.
Quoted 9 lines
Quoted 3 lines
And the original author of the commit, that introduced the issue too.
Suzuki
Hi All,
Thanks for the discussion and feedbacks.This patch fixes the shellcheck warning introduced in function "
cs_etm_dev_name". But with the changes that Suzuki suggested, we won't need the function "cs_etm_dev_name" since the code will use "/sys/bus/event_source/devices/cs_etm/" . In that case, can I drop this patch for now from this series ?
Yes, please. James will send out the proposed patch
Suzuki
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
Quoted 61 lines · Suzuki K Poulose
Hi,
Quoted 6 lines · Athira Rajeev
Quoted 6 lines · Suzuki K Poulose
Quoted 3 lines · Namhyung Kim
Quoted 1 line · Athira Rajeev
...
Quoted 45 lines
Quoted 45 lines
Thanks for the fix.
Nothing to do with this patch, but I am wondering if the original patch is over engineered and may not be future proof.
e.g.,
cs_etm_dev_name(){
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)Right there you got the device name and we can easily deduce the name of the "ETM" node.
e.g,:
etm=$(basename $(readlinkcs_etm_path) | sed "s/[0-9]\+$//")And practically, nobody prevents an ETE mixed with an ETM on a "hybrid" system (hopefully, no one builds it ;-))
Also, instead of hardcoding "ete" and "etm" prefixes from the arch part, we should simply use the cpu nodes from :
/sys/bus/event_source/devices/cs_etm/e.g.,
arm_cs_etm_traverse_path_test(){
# Iterate for every ETM device
for c in/sys/bus/event_source/devices/cs_etm/cpu*; do # Read the link to be on the safer side dev=readlink $c# Find the ETM device belonging to which CPU
cpu=cat $dev/cpu# Use depth-first search (DFS) to iterate outputs
arm_cs_iterate_devices$dev $cpu
done;
}Quoted 2 lines
You'd better add Coresight folks on this. Maybe this file was missing in the
MAINTAINERSfile.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
And the original author of the commit, that introduced the issue too.
Suzuki
Hi All,
Thanks for the discussion and feedbacks.
This patch fixes the shellcheck warning introduced in function "cs_etm_dev_name". But with the changes that Suzuki suggested, we won't need the function "cs_etm_dev_name" since the code will use "/sys/bus/event_source/devices/cs_etm/" . In that case, can I drop this patch for now from this series ?Yes, please. James will send out the proposed patch
Hi Suzuki,
Sure. Thanks!
Athira
Quoted 4 lines
Suzuki
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
In reply to Athira RajeevEm Thu, Oct 05, 2023 at 02:24:15PM +0530, Athira Rajeev escreveu:
Quoted 39 lines
Quoted 39 lines · James Clark
Quoted 37 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>---
tools/perf/tests/shell/test_arm_coresight.sh| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +0
-0@@ -12,12 +12,12 @@glb_err=0
cs_etm_dev_name(){
- cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) &0xf))
archpart=$(($trcdevarch &0xfff))
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
- if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "
0xA13" ] ; then
+ if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete"
else
echo "etm"Reviewed-by James Clark <[email protected]>
Some are not applying, even after b4 picking up v2
Total patches: 3
---
Cover: ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.cover
Base: not specified
git am ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.mbx
⬢[acme@toolbox perf-tools-next]$ git am ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.mbx
Applying: tools/perf/tests Ignore the shellcheck SC2046 warning in lock_contention
error: patch failed: tools/perf/tests/shell/lock_contention.sh:33
error: tools/perf/tests/shell/lock_contention.sh: patch does not apply
Patch failed at 0001 tools/perf/tests Ignore the shellcheck SC2046 warning in lock_contention
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort". ⬢[acme@toolbox perf-tools-next]$ git am --abort
⬢[acme@toolbox perf-tools-next]$
Re: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
Quoted 61 lines · Arnaldo Carvalho de Melo
Em Thu, Oct 05, 2023 at 02:24:15PM +0530, Athira Rajeev escreveu:
Quoted 39 lines
Quoted 39 lines · James Clark
Quoted 37 lines · Athira Rajeev
Running shellcheck on
tests/shell/test_arm_coresight.shthrows below warnings:In
tests/shell/test_arm_coresight.shline 15:
cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
^--^ SC2061: Quote the parameter to -name so the shell won't interpret it.In
tests/shell/test_arm_coresight.shline 20:
if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well definedThis warning is observed after commit:
"commitbb350847965d("perf test: Updatecs_etmtestcase for Arm ETE")"Fixed this issue by using quoting 'cpu*' for SC2061 and using "&&" in line number 20 for SC2166 warning
Fixes bb350847965d ("perf test: Update cs_etm testcase for Arm ETE")Signed-off-by Athira Rajeev <[email protected]>---
tools/perf/tests/shell/test_arm_coresight.sh| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/test_arm_coresight.sh +0
-0@@ -12,12 +12,12 @@glb_err=0
cs_etm_dev_name(){
- cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name cpu* -print -quit)
+ cs_etm_path=$(find/sys/bus/event_source/devices/cs_etm/-name 'cpu*' -print -quit) trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) archhver=$((($trcdevarch >> 12) &0xf))
archpart=$(($trcdevarch &0xfff))Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
- if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "
0xA13" ] ; then
+ if [ $archhver -eq 5 ] && [ "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then echo "ete"
else
echo "etm"Reviewed-by James Clark <[email protected]>Some are not applying, even after b4 picking up v2
Total patches: 3
---
Cover: ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.coverBase: not specified
git am ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.mbx
Quoted 11 lines
⬢[acme@toolbox perf-tools-next]$ git am ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.mbx
Applying:tools/perf/testsIgnore the shellcheck SC2046 warning inlock_contention
error: patch failed:tools/perf/tests/shell/lock_contention.sh:33
error:tools/perf/tests/shell/lock_contention.sh: patch does not apply
Patch failed at 0001tools/perf/testsIgnore the shellcheck SC2046 warning inlock_contention
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort". ⬢[acme@toolbox perf-tools-next]$ git am --abort
⬢[acme@toolbox perf-tools-next]$
Hi Arnaldo
The patch is picked up : https://lore.kernel.org/all/[email protected]/ . Thanks for looking into.
Athira
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 1/3] perf tests test_arm_coresight: Fix the shellcheck warning in latest test_arm_coresight.sh
Em Tue, Nov 07, 2023 at 12:08:25PM +0530, Athira Rajeev escreveu:
Quoted 23 lines
Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 1 line
Quoted 1 line
Reviewed-by James Clark <[email protected]>Some are not applying, even after b4 picking up v2
Total patches: 3
Cover: ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.cover
Base: not specified
git am ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.mbxQuoted 11 lines
⬢[acme@toolbox perf-tools-next]$ git am ./v2_20231013_atrajeev_fix_for_shellcheck_issues_with_latest_scripts_in_tests_shell.mbx
Applying:tools/perf/testsIgnore the shellcheck SC2046 warning inlock_contention
error: patch failed:tools/perf/tests/shell/lock_contention.sh:33
error:tools/perf/tests/shell/lock_contention.sh: patch does not apply
Patch failed at 0001tools/perf/testsIgnore the shellcheck SC2046 warning inlock_contention
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort". ⬢[acme@toolbox perf-tools-next]$ git am --abort
⬢[acme@toolbox perf-tools-next]$
Quoted 2 lines
The patch is picked up : https://lore.kernel.org/all/[email protected]/ . Thanks for looking into.
Thanks for checking, my mistake then,
- Arnaldo