2023-11-23 08:00:24

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH 0/8] perf tests: Reduce inexplicable test failures

Hi

Here are some small changes to help reduce inexplicable perf test failures.

Regards
Adrian


2023-11-23 08:00:23

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH 5/8] perf tests: Skip Arm64 callgraphs test if leafloop symbol is missing

The test "Check Arm64 callgraphs are complete in fp mode" depends on
finding symbol leafloop in perf, and fails if perf has been stripped and no
debug object is available. In that case, skip the test instead.

Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/tests/shell/test_arm_callgraph_fp.sh | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/perf/tests/shell/test_arm_callgraph_fp.sh b/tools/perf/tests/shell/test_arm_callgraph_fp.sh
index 66dfdfdad553..e342e6c8aa50 100755
--- a/tools/perf/tests/shell/test_arm_callgraph_fp.sh
+++ b/tools/perf/tests/shell/test_arm_callgraph_fp.sh
@@ -2,8 +2,14 @@
# Check Arm64 callgraphs are complete in fp mode
# SPDX-License-Identifier: GPL-2.0

+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
lscpu | grep -q "aarch64" || exit 2

+skip_test_missing_symbol leafloop
+
PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
TEST_PROGRAM="perf test -w leafloop"

--
2.34.1

2023-11-23 08:00:25

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH 4/8] perf tests: Skip record test if test_loop symbol is missing

perf record test depends on finding symbol test_loop in perf, and fails if
perf has been stripped and no debug object is available. In that case, skip
the test instead.

Example:

Note, building with perl support adds option -Wl,-E which causes the
linker to add all (global) symbols to the dynamic symbol table. So the
test_loop symbol, being global, does not get stripped unless NO_LIBPERL=1

Before:

$ make NO_LIBPERL=1 -C tools/perf >/dev/null 2>&1
$ strip tools/perf/perf
$ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
$ tools/perf/perf test -v 'record tests'
91: perf record tests :
--- start ---
test child forked, pid 118750
Basic --per-thread mode test
Per-thread record [Failed missing output]
Register capture test
Register capture test [Success]
Basic --system-wide mode test
System-wide record [Skipped not supported]
Basic target workload test
Workload record [Failed missing output]
test child finished with -1
---- end ----
perf record tests: FAILED!

After:

$ tools/perf/perf test -v 'record tests'
91: perf record tests :
--- start ---
test child forked, pid 120025
perf does not have symbol 'test_loop'
perf is missing symbols - skipping test
test child finished with -2
---- end ----
perf record tests: Skip

Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/tests/shell/record.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 29443b8e8876..1838b76e2282 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -8,10 +8,16 @@ shelldir=$(dirname "$0")
# shellcheck source=lib/waiting.sh
. "${shelldir}"/lib/waiting.sh

+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
+testsym="test_loop"
+
+skip_test_missing_symbol ${testsym}
+
err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
testprog="perf test -w thloop"
-testsym="test_loop"

cleanup() {
rm -rf "${perfdata}"
--
2.34.1

2023-11-23 08:00:27

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH 7/8] perf tests: Make data symbol test wait for perf to start

The perf data symbol test waits 1 second for perf to run and collect data,
which may be too little if perf takes a long time to start up, which has
been noticed on systems with many CPUs. Use existing wait_for_perf_to_start
helper to wait for perf to start.

Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/tests/shell/test_data_symbol.sh | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/shell/test_data_symbol.sh
index 69bb6fe86c50..e50e54e94f6f 100755
--- a/tools/perf/tests/shell/test_data_symbol.sh
+++ b/tools/perf/tests/shell/test_data_symbol.sh
@@ -4,6 +4,10 @@
# SPDX-License-Identifier: GPL-2.0
# Leo Yan <[email protected]>, 2022

+shelldir=$(dirname "$0")
+# shellcheck source=lib/waiting.sh
+. "${shelldir}"/lib/waiting.sh
+
skip_if_no_mem_event() {
perf mem record -e list 2>&1 | grep -E -q 'available' && return 0
return 2
@@ -13,6 +17,7 @@ skip_if_no_mem_event || exit 2

TEST_PROGRAM="perf test -w datasym"
PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+ERR_FILE=$(mktemp /tmp/__perf_test.stderr.XXXXX)

check_result() {
# The memory report format is as below:
@@ -50,13 +55,15 @@ echo "Recording workload..."
# specific CPU and test in per-CPU mode.
is_amd=$(grep -E -c 'vendor_id.*AuthenticAMD' /proc/cpuinfo)
if (($is_amd >= 1)); then
- perf mem record -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM &
+ perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}" &
else
- perf mem record --all-user -o ${PERF_DATA} -- $TEST_PROGRAM &
+ perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}" &
fi

PERFPID=$!

+wait_for_perf_to_start ${PERFPID} "${ERR_FILE}"
+
sleep 1

kill $PERFPID
--
2.34.1

2023-11-23 08:02:03

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH 8/8] perf tests: Skip data symbol test if buf1 symbol is missing

perf data symbol test depends on finding symbol buf1 in perf, and fails if
perf has been stripped and no debug object is available. In that case, skip
the test instead.

Example:

Before:

$ strip tools/perf/perf
$ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
$ tools/perf/perf test -v 'data symbol'
113: Test data symbol :
--- start ---
test child forked, pid 125646
Recording workload...
[ perf record: Woken up 3 times to write data ]
[ perf record: Captured and wrote 0.577 MB /tmp/__perf_test.perf.data.Jhbdp (7794 samples) ]
Cleaning up files...
test child finished with -1
---- end ----
Test data symbol: FAILED!

After:

$ tools/perf/perf test -v 'data symbol'
113: Test data symbol :
--- start ---
test child forked, pid 125747
perf does not have symbol 'buf1'
perf is missing symbols - skipping test
test child finished with -2
---- end ----
Test data symbol: Skip

Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/tests/shell/test_data_symbol.sh | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/shell/test_data_symbol.sh
index e50e54e94f6f..3dfa91832aa8 100755
--- a/tools/perf/tests/shell/test_data_symbol.sh
+++ b/tools/perf/tests/shell/test_data_symbol.sh
@@ -8,6 +8,9 @@ shelldir=$(dirname "$0")
# shellcheck source=lib/waiting.sh
. "${shelldir}"/lib/waiting.sh

+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
skip_if_no_mem_event() {
perf mem record -e list 2>&1 | grep -E -q 'available' && return 0
return 2
@@ -15,6 +18,8 @@ skip_if_no_mem_event() {

skip_if_no_mem_event || exit 2

+skip_test_missing_symbol buf1
+
TEST_PROGRAM="perf test -w datasym"
PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
ERR_FILE=$(mktemp /tmp/__perf_test.stderr.XXXXX)
--
2.34.1

2023-11-23 08:02:47

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH 3/8] perf tests: Skip pipe test if noploop symbol is missing

perf pipe recording and injection test depends on finding symbol noploop in
perf, and fails if perf has been stripped and no debug object is available.
In that case, skip the test instead.

Example:

Before:

$ strip tools/perf/perf
$ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
$ tools/perf/perf test -v pipe
86: perf pipe recording and injection test :
--- start ---
test child forked, pid 47734
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
47741 47741 -1 |perf
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
cannot find noploop function in pipe #1
test child finished with -1
---- end ----
perf pipe recording and injection test: FAILED!

After:

$ tools/perf/perf test -v pipe
86: perf pipe recording and injection test :
--- start ---
test child forked, pid 48996
perf does not have symbol 'noploop'
perf is missing symbols - skipping test
test child finished with -2
---- end ----
perf pipe recording and injection test: Skip

Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/tests/shell/pipe_test.sh | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/pipe_test.sh b/tools/perf/tests/shell/pipe_test.sh
index 8dd115dd35a7..a78d35d2cff0 100755
--- a/tools/perf/tests/shell/pipe_test.sh
+++ b/tools/perf/tests/shell/pipe_test.sh
@@ -2,10 +2,17 @@
# perf pipe recording and injection test
# SPDX-License-Identifier: GPL-2.0

+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
+sym="noploop"
+
+skip_test_missing_symbol ${sym}
+
data=$(mktemp /tmp/perf.data.XXXXXX)
prog="perf test -w noploop"
task="perf"
-sym="noploop"

if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep ${task}; then
echo "cannot find the test file in the perf report"
--
2.34.1

2023-11-23 14:07:16

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/8] perf tests: Reduce inexplicable test failures

Em Thu, Nov 23, 2023 at 09:58:40AM +0200, Adrian Hunter escreveu:
> Here are some small changes to help reduce inexplicable perf test failures.

Looks ok, applying to perf-tools-next, had to remove a patch adding a
new test, by Kan Liang, then reapply it on top of your series, git
managed to sort it out:

https://lore.kernel.org/r/[email protected]


- Arnaldo

2023-11-27 07:19:48

by Athira Rajeev

[permalink] [raw]
Subject: Re: [PATCH 0/8] perf tests: Reduce inexplicable test failures



> On 23-Nov-2023, at 7:36 PM, Arnaldo Carvalho de Melo <[email protected]> wrote:
>
> Em Thu, Nov 23, 2023 at 09:58:40AM +0200, Adrian Hunter escreveu:
>> Here are some small changes to help reduce inexplicable perf test failures.
>
> Looks ok, applying to perf-tools-next, had to remove a patch adding a
> new test, by Kan Liang, then reapply it on top of your series, git
> managed to sort it out:

Hi Arnaldo,

I didn’t find this in either of these places:
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=perf-tools-next
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-next

Sorry if I missed checking correct location. Can you please point to git link ?

Thanks
Athira
>
> https://lore.kernel.org/r/[email protected]
>
>
> - Arnaldo

2023-11-27 13:24:28

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/8] perf tests: Reduce inexplicable test failures

Em Mon, Nov 27, 2023 at 12:49:13PM +0530, Athira Rajeev escreveu:
>
>
> > On 23-Nov-2023, at 7:36 PM, Arnaldo Carvalho de Melo <[email protected]> wrote:
> >
> > Em Thu, Nov 23, 2023 at 09:58:40AM +0200, Adrian Hunter escreveu:
> >> Here are some small changes to help reduce inexplicable perf test failures.
> >
> > Looks ok, applying to perf-tools-next, had to remove a patch adding a
> > new test, by Kan Liang, then reapply it on top of your series, git
> > managed to sort it out:
>
> Hi Arnaldo,
>
> I didn’t find this in either of these places:
> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=perf-tools-next
> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-next

I was still testing it on the containers setup, it is at:

https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=tmp.perf-tools-next
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=tmp.perf-tools-next

And will move to the perf-tools-next branches soon, I just collected
some more acked-by for some patches in the tmp branch and will push the
updated branch.

- Arnaldo

> Sorry if I missed checking correct location. Can you please point to git link ?
>
> Thanks
> Athira
> >
> > https://lore.kernel.org/r/[email protected]
> >
> >
> > - Arnaldo
>

--

- Arnaldo

2023-11-27 14:32:45

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/8] perf tests: Reduce inexplicable test failures

Em Mon, Nov 27, 2023 at 10:23:45AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Nov 27, 2023 at 12:49:13PM +0530, Athira Rajeev escreveu:
> > > On 23-Nov-2023, at 7:36 PM, Arnaldo Carvalho de Melo <[email protected]> wrote:
> > I didn’t find this in either of these places:
> > https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=perf-tools-next
> > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=perf-tools-next
>
> I was still testing it on the containers setup, it is at:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=tmp.perf-tools-next
> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=tmp.perf-tools-next
>
> And will move to the perf-tools-next branches soon, I just collected
> some more acked-by for some patches in the tmp branch and will push the
> updated branch.

Done.

- Arnaldo

2023-11-27 17:35:29

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH 0/8] perf tests: Reduce inexplicable test failures

On Wed, Nov 22, 2023 at 11:59 PM Adrian Hunter <[email protected]> wrote:
>
> Hi
>
> Here are some small changes to help reduce inexplicable perf test failures.
>
> Regards
> Adrian

Thanks for doing this!

Acked-by: Ian Rogers <[email protected]>

Thanks,
Ian