Skip to contentSkip to conversation

Please backport subset of 2f5d370dec3f ("perf test: Change all remaining #!/bin/sh to #!/bin/bash") for stat_bpf_counters.sh script to v6.12.y and older

PATCH Salvatore Bonaccorso 3 participants 4 messages Sep 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi

Recently for v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52 and v7.2.6, the commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported, but it introduced bash specific syntax. For versions after 2f5d370dec3f ("perf test:
Change all remaining #!/bin/sh to #!/bin/bash") aka before v6.17-rc1 this is not a problem.

The proposed patch is a stable series backports specific one, as one cannot simply backport 2f5d370dec3f ("perf test: Change all remaining #!/bin/sh to #!/bin/bash") without picking as well some other context related changes to make it possible. So I was proposing to only change shebang to #!/bin/bash in stable series were it is a problem, as in the stat_bpf_counters.sh script.

Regards,
Salvatore

From 1e3d5b5f62047b147428d20bf2cb794bb0bb300d Mon Sep 17 00:00:00 2001
From: Salvatore Bonaccorso <[email protected]>
Date: Fri, 18 Sep 2026 20:48:59 +0200
Subject: [PATCH] perf tests: Change shebang for stat_bpf_counters.sh to
#!/bin/bash

When commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported to several stable series (v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52, v7.2.6) it introduced specific bash syntax. For versions after 2f5d370dec3f ("perf
test: Change all remaining #!/bin/sh to #!/bin/bash") in v6.17-rc1 this is not a problem as the shebang was already hanged to #!/bin/bash. For the older stable series this introduced invalid syntax if #!/bin/sh is not bash:

	$ sh -n tools/perf/tests/shell/stat_bpf_counters.sh
	tools/perf/tests/shell/stat_bpf_counters.sh: 12: Syntax error: "(" unexpected
	$ checkbashism tools/perf/tests/shell/stat_bpf_counters.sh
	possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 52 (bash arrays, ${name[0|*|@]}):
		base_instructions=$(perf stat --no-big-num -e instructions:u -- "${workload[@]}" 2>&1 | \
					awk -v i=0 -v c=0 '/instructions/ { \
						if ($1 != "<not") { i++; c += $1 } \
					} END { if (i > 0) printf "%.0f", c; else print "<not" }')
	possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 57 (bash arrays, ${name[0|*|@]}):
		bpf_instructions=$(perf stat --no-big-num --bpf-counters -e instructions:u \
					-- "${workload[@]}"  2>&1 | \
					awk -v i=0 -v c=0 '/instructions/ { \
						if ($1 != "<not") { i++; c += $1 } \
					} END { if (i > 0) printf "%.0f", c; else print "<not" }')
	possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 68 (bash arrays, ${name[0|*|@]}):
		stat_output=$(perf stat --no-big-num \
			-e instructions/name=base_instructions/u,instructions/name=bpf_instructions/bu \
			-- "${workload[@]}" 2>&1)

Change shebang for the stat_bpf_counters.sh script.

No upstream commit exists for this change as for versions post 6.17-rc1 the scripts were converted to #!/bin/bash already.

---
 tools/perf/tests/shell/stat_bpf_counters.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat_bpf_counters.sh +1 -1
index 76d4a7f15a43..c4f71bfc0fc6 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat --bpf-counters test
 # SPDX-License-Identifier: GPL-2.0
 
Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 17 lines

Hi

Recently for v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52 and v7.2.6, the commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported, but it introduced bash specific syntax. For versions after 2f5d370dec3f ("perf test:
Change all remaining #!/bin/sh to #!/bin/bash") aka before v6.17-rc1 this is not a problem.

The proposed patch is a stable series backports specific one, as one cannot simply backport 2f5d370dec3f ("perf test: Change all remaining #!/bin/sh to #!/bin/bash") without picking as well some other context related changes to make it possible. So I was proposing to only change shebang to #!/bin/bash in stable series were it is a problem, as in the stat_bpf_counters.sh script.
[ ... ]

Quoted 4 lines

No upstream commit exists for this change as for versions post 6.17-rc1 the scripts were converted to #!/bin/bash already.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Salvatore Bonaccorso

Hi,

Quoted 9 lines · Salvatore Bonaccorso

Hi

Recently for v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52 and v7.2.6, the commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported, but it introduced bash specific syntax. For versions after 2f5d370dec3f ("perf test:
Change all remaining #!/bin/sh to #!/bin/bash") aka before v6.17-rc1 this is not a problem.

Quoted 6 lines

The proposed patch is a stable series backports specific one, as one cannot simply backport 2f5d370dec3f ("perf test: Change all remaining #!/bin/sh to #!/bin/bash") without picking as well some other context related changes to make it possible. So I was proposing to only change shebang to #!/bin/bash in stable series were it is a problem, as in the stat_bpf_counters.sh script.

"Obviously" there was a typo in the commit message and a missing explanation, thus v2 of the proposed change as follows.

Regards,
Salvatore

From 804ae26dab32c846467d7b7887d8f7dcd3348fa5 Mon Sep 17 00:00:00 2001
From: Salvatore Bonaccorso <[email protected]>
Date: Fri, 18 Sep 2026 20:48:59 +0200
Subject: [PATCH] perf tests: Change shebang for stat_bpf_counters.sh to
#!/bin/bash

When commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported to several stable series (v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52, v7.2.6) it introduced specific bash syntax. For versions after 2f5d370dec3f ("perf
test: Change all remaining #!/bin/sh to #!/bin/bash") in v6.17-rc1 this is not a problem as the shebang was already changed to #!/bin/bash. For the older stable series this introduced invalid syntax if #!/bin/sh is not bash:

	$ sh -n tools/perf/tests/shell/stat_bpf_counters.sh
	tools/perf/tests/shell/stat_bpf_counters.sh: 12: Syntax error: "(" unexpected
	$ checkbashism tools/perf/tests/shell/stat_bpf_counters.sh
	possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 52 (bash arrays, ${name[0|*|@]}):
		base_instructions=$(perf stat --no-big-num -e instructions:u -- "${workload[@]}" 2>&1 | \
					awk -v i=0 -v c=0 '/instructions/ { \
						if ($1 != "<not") { i++; c += $1 } \
					} END { if (i > 0) printf "%.0f", c; else print "<not" }')
	possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 57 (bash arrays, ${name[0|*|@]}):
		bpf_instructions=$(perf stat --no-big-num --bpf-counters -e instructions:u \
					-- "${workload[@]}"  2>&1 | \
					awk -v i=0 -v c=0 '/instructions/ { \
						if ($1 != "<not") { i++; c += $1 } \
					} END { if (i > 0) printf "%.0f", c; else print "<not" }')
	possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 68 (bash arrays, ${name[0|*|@]}):
		stat_output=$(perf stat --no-big-num \
			-e instructions/name=base_instructions/u,instructions/name=bpf_instructions/bu \
			-- "${workload[@]}" 2>&1)

Change shebang for the stat_bpf_counters.sh script to #!/bin/bash.

No upstream commit exists for this change as for versions post 6.17-rc1 the scripts were converted to #!/bin/bash already.

---
v2:
- Fixed a typo in commit message: hanged -> changed
- Explicit state to what shebang was changed for stat_bpf_counters.sh script.

 tools/perf/tests/shell/stat_bpf_counters.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat_bpf_counters.sh +1 -1
index 76d4a7f15a43..c4f71bfc0fc6 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat --bpf-counters test
 # SPDX-License-Identifier: GPL-2.0
 
Signature · 1 line
2.55.0
reviewer Reviewed-by
#3 lore raw
Quoted 61 lines · Salvatore Bonaccorso

Hi,

Quoted 9 lines · Salvatore Bonaccorso

Hi

Recently for v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52 and v7.2.6, the commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported, but it introduced bash specific syntax. For versions after 2f5d370dec3f ("perf test:
Change all remaining #!/bin/sh to #!/bin/bash") aka before v6.17-rc1 this is not a problem.

Quoted 6 lines

The proposed patch is a stable series backports specific one, as one cannot simply backport 2f5d370dec3f ("perf test: Change all remaining #!/bin/sh to #!/bin/bash") without picking as well some other context related changes to make it possible. So I was proposing to only change shebang to #!/bin/bash in stable series were it is a problem, as in the stat_bpf_counters.sh script.

"Obviously" there was a typo in the commit message and a missing explanation, thus v2 of the proposed change as follows.

Regards,
Salvatore

From 804ae26dab32c846467d7b7887d8f7dcd3348fa5 Mon Sep 17 00:00:00 2001
From: Salvatore Bonaccorso <[email protected]>
Date: Fri, 18 Sep 2026 20:48:59 +0200
Subject: [PATCH] perf tests: Change shebang for stat_bpf_counters.sh to
#!/bin/bash

When commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported to several stable series (v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52, v7.2.6) it introduced specific bash syntax. For versions after 2f5d370dec3f ("perf
test: Change all remaining #!/bin/sh to #!/bin/bash") in v6.17-rc1 this is not a problem as the shebang was already changed to #!/bin/bash. For the older stable series this introduced invalid syntax if #!/bin/sh is not bash:

        $ sh -n tools/perf/tests/shell/stat_bpf_counters.sh
        tools/perf/tests/shell/stat_bpf_counters.sh: 12: Syntax error: "(" unexpected
        $ checkbashism tools/perf/tests/shell/stat_bpf_counters.sh
        possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 52 (bash arrays, ${name[0|*|@]}):
                base_instructions=$(perf stat --no-big-num -e instructions:u -- "${workload[@]}" 2>&1 | \
                                        awk -v i=0 -v c=0 '/instructions/ { \
                                                if ($1 != "<not") { i++; c += $1 } \
                                        } END { if (i > 0) printf "%.0f", c; else print "<not" }')
        possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 57 (bash arrays, ${name[0|*|@]}):
                bpf_instructions=$(perf stat --no-big-num --bpf-counters -e instructions:u \
                                        -- "${workload[@]}"  2>&1 | \
                                        awk -v i=0 -v c=0 '/instructions/ { \
                                                if ($1 != "<not") { i++; c += $1 } \
                                        } END { if (i > 0) printf "%.0f", c; else print "<not" }')
        possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 68 (bash arrays, ${name[0|*|@]}):
                stat_output=$(perf stat --no-big-num \
                        -e instructions/name=base_instructions/u,instructions/name=bpf_instructions/bu \
                        -- "${workload[@]}" 2>&1)
Quoted 6 lines

Change shebang for the stat_bpf_counters.sh script to #!/bin/bash.

No upstream commit exists for this change as for versions post 6.17-rc1 the scripts were converted to #!/bin/bash already.

This should have been caught by the perf tool build as that build runs shellcheck on all tests when shellcheck is available. Maybe there should be an action to run perf builds as part of the stable backports when the tools/perf directory is touched.

Thanks,
Ian

Quoted 22 lines

---
v2:
- Fixed a typo in commit message: hanged -> changed
- Explicit state to what shebang was changed for stat_bpf_counters.sh script.

 tools/perf/tests/shell/stat_bpf_counters.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat_bpf_counters.sh +1 -2
index 76d4a7f15a43..c4f71bfc0fc6 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat --bpf-counters test
 # SPDX-License-Identifier: GPL-2.0
 
--

2.55.0