Commit 6b7e02ab authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf test: Wait for a new thread when testing --per-thread record

Just running the target program is not enough to test multi-thread
target because it'd be racy perf vs target startup.  I used the
initial delay but it cannot guarantee for perf to see the thread.

Instead, use wait_for_threads helper from shell/lib/waiting.sh to make
sure it starts the sibling thread first.  Then perf record can use -p
option to profile the target process.
Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarIan Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20221020172643.3458767-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4321ad4e
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
set -e set -e
shelldir=$(dirname "$0")
. "${shelldir}"/lib/waiting.sh
err=0 err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX) testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
...@@ -96,6 +99,30 @@ test_per_thread() { ...@@ -96,6 +99,30 @@ test_per_thread() {
err=1 err=1
return return
fi fi
# run the test program in background (forever)
${testprog} 1 &
TESTPID=$!
rm -f "${perfdata}"
wait_for_threads ${TESTPID} 2
perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
kill ${TESTPID}
if [ ! -e "${perfdata}" ]
then
echo "Per-thread record [Failed record -p]"
err=1
return
fi
if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
then
echo "Per-thread record [Failed -p missing output]"
err=1
return
fi
echo "Basic --per-thread mode test [Success]" echo "Basic --per-thread mode test [Success]"
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment