Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf test: Make test_arm_callgraph_fp.sh more robust

The 2 second sleep can cause the test to fail on very slow network file
systems because Perf ends up being killed before it finishes starting
up.

Fix it by making the leafloop workload end after a fixed time like the
other workloads so there is no need to kill it after 2 seconds.

Also remove the 1 second start sampling delay because it is similarly
fragile. Instead, search through all samples for a matching one, rather
than just checking the first sample and hoping it's in the right place.

Fixes: cd6382d82752 ("perf test arm64: Test unwinding using fame-pointer (fp) mode")
Signed-off-by: James Clark <james.clark@arm.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: German Gomez <german.gomez@arm.com>
Cc: Spoorthy S <spoorts2@in.ibm.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240612140316.3006660-1-james.clark@arm.com

authored by

James Clark and committed by
Namhyung Kim
ff16aeb9 366e1740

+26 -21
+10 -17
tools/perf/tests/shell/test_arm_callgraph_fp.sh
··· 28 28 29 29 trap cleanup_files EXIT TERM INT 30 30 31 - # Add a 1 second delay to skip samples that are not in the leaf() function 32 31 # shellcheck disable=SC2086 33 - perf record -o "$PERF_DATA" --call-graph fp -e cycles//u -D 1000 --user-callchains -- $TEST_PROGRAM 2> /dev/null & 34 - PID=$! 32 + perf record -o "$PERF_DATA" --call-graph fp -e cycles//u --user-callchains -- $TEST_PROGRAM 35 33 36 - echo " + Recording (PID=$PID)..." 37 - sleep 2 38 - echo " + Stopping perf-record..." 34 + # Try opening the file so any immediate errors are visible in the log 35 + perf script -i "$PERF_DATA" -F comm,ip,sym | head -n4 39 36 40 - kill $PID 41 - wait $PID 42 - 43 - # expected perf-script output: 37 + # expected perf-script output if 'leaf' has been inserted correctly: 44 38 # 45 - # program 39 + # perf 46 40 # 728 leaf 47 41 # 753 parent 48 42 # 76c leafloop 49 - # ... 43 + # ... remaining stack to main() ... 50 44 51 - perf script -i "$PERF_DATA" -F comm,ip,sym | head -n4 52 - perf script -i "$PERF_DATA" -F comm,ip,sym | head -n4 | \ 53 - awk '{ if ($2 != "") sym[i++] = $2 } END { if (sym[0] != "leaf" || 54 - sym[1] != "parent" || 55 - sym[2] != "leafloop") exit 1 }' 45 + # Each frame is separated by a tab, some spaces and an address 46 + SEP="[[:space:]]+ [[:xdigit:]]+" 47 + perf script -i "$PERF_DATA" -F comm,ip,sym | tr '\n' ' ' | \ 48 + grep -E -q "perf $SEP leaf $SEP parent $SEP leafloop"
+16 -4
tools/perf/tests/workloads/leafloop.c
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + #include <signal.h> 2 3 #include <stdlib.h> 3 4 #include <linux/compiler.h> 5 + #include <unistd.h> 4 6 #include "../tests.h" 5 7 6 8 /* We want to check these symbols in perf script */ ··· 10 8 noinline void parent(volatile int b); 11 9 12 10 static volatile int a; 11 + static volatile sig_atomic_t done; 12 + 13 + static void sighandler(int sig __maybe_unused) 14 + { 15 + done = 1; 16 + } 13 17 14 18 noinline void leaf(volatile int b) 15 19 { 16 - for (;;) 20 + while (!done) 17 21 a += b; 18 22 } 19 23 ··· 30 22 31 23 static int leafloop(int argc, const char **argv) 32 24 { 33 - int c = 1; 25 + int sec = 1; 34 26 35 27 if (argc > 0) 36 - c = atoi(argv[0]); 28 + sec = atoi(argv[0]); 37 29 38 - parent(c); 30 + signal(SIGINT, sighandler); 31 + signal(SIGALRM, sighandler); 32 + alarm(sec); 33 + 34 + parent(sec); 39 35 return 0; 40 36 } 41 37