Skip to content

Commit 9a8dd2f

Browse files
captain5050acmel
authored andcommitted
perf test shell daemon: Make signal test less racy
The daemon signal test sends signals and then expects files to be written. It was observed on an Intel Alderlake that the signals were sent too quickly leading to the 3 expected files not appearing. To avoid this send the next signal only after the expected previous file has appeared. To avoid an infinite loop the number of retries is limited. Signed-off-by: Ian Rogers <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Ross Zwisler <[email protected]> Cc: Shirisha G <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1c2124e commit 9a8dd2f

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

tools/perf/tests/shell/daemon.sh

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,30 @@ EOF
414414
# start daemon
415415
daemon_start ${config} test
416416

417-
# send 2 signals
418-
perf daemon signal --config ${config} --session test
419-
perf daemon signal --config ${config}
420-
421-
# stop daemon
422-
daemon_exit ${config}
423-
424-
# count is 2 perf.data for signals and 1 for perf record finished
425-
count=`ls ${base}/session-test/*perf.data* | wc -l`
426-
if [ ${count} -ne 3 ]; then
417+
# send 2 signals then exit. Do this in a loop watching the number of
418+
# files to avoid races. If the loop retries more than 600 times then
419+
# give up.
420+
local retries=0
421+
local signals=0
422+
local success=0
423+
while [ ${retries} -lt 600 ] && [ ${success} -eq 0 ]; do
424+
local files
425+
files=`ls ${base}/session-test/*perf.data* 2> /dev/null | wc -l`
426+
if [ ${signals} -eq 0 ]; then
427+
perf daemon signal --config ${config} --session test
428+
signals=1
429+
elif [ ${signals} -eq 1 ] && [ $files -ge 1 ]; then
430+
perf daemon signal --config ${config}
431+
signals=2
432+
elif [ ${signals} -eq 2 ] && [ $files -ge 2 ]; then
433+
daemon_exit ${config}
434+
signals=3
435+
elif [ ${signals} -eq 3 ] && [ $files -ge 3 ]; then
436+
success=1
437+
fi
438+
retries=$((${retries} +1))
439+
done
440+
if [ ${success} -eq 0 ]; then
427441
error=1
428442
echo "FAILED: perf data no generated"
429443
fi

0 commit comments

Comments
 (0)