Commit 79b7ca78 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf test: Add more test cases for perf lock contention

Check callstack filter with two different aggregation mode.

  $ sudo ./perf test -v contention
   88: kernel lock contention analysis test                            :
  --- start ---
  test child forked, pid 83416
  Testing perf lock record and perf lock contention
  Testing perf lock contention --use-bpf
  Testing perf lock record and perf lock contention at the same time
  Testing perf lock contention --threads
  Testing perf lock contention --lock-addr
  Testing perf lock contention --type-filter (w/ spinlock)
  Testing perf lock contention --lock-filter (w/ tasklist_lock)
  Testing perf lock contention --callstack-filter (w/ unix_stream)
  Testing perf lock contention --callstack-filter with task aggregation
  test child finished with 0
  ---- end ----
  kernel lock contention analysis test: Ok
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230202050455.2187592-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 540f8b56
...@@ -128,7 +128,7 @@ test_type_filter() ...@@ -128,7 +128,7 @@ test_type_filter()
echo "Testing perf lock contention --type-filter (w/ spinlock)" echo "Testing perf lock contention --type-filter (w/ spinlock)"
perf lock contention -i ${perfdata} -Y spinlock -q 2> ${result} perf lock contention -i ${perfdata} -Y spinlock -q 2> ${result}
if [ $(grep -c -v spinlock "${result}") != "0" ]; then if [ $(grep -c -v spinlock "${result}") != "0" ]; then
echo "[Fail] Recorded should not have non-spinlocks:" $(cat "${result}") echo "[Fail] Recorded result should not have non-spinlocks:" $(cat "${result}")
err=1 err=1
exit exit
fi fi
...@@ -139,7 +139,7 @@ test_type_filter() ...@@ -139,7 +139,7 @@ test_type_filter()
perf lock con -a -b -Y spinlock -q -- perf bench sched messaging > /dev/null 2> ${result} perf lock con -a -b -Y spinlock -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(grep -c -v spinlock "${result}") != "0" ]; then if [ $(grep -c -v spinlock "${result}") != "0" ]; then
echo "[Fail] Recorded should not have non-spinlocks:" $(cat "${result}") echo "[Fail] BPF result should not have non-spinlocks:" $(cat "${result}")
err=1 err=1
exit exit
fi fi
...@@ -160,7 +160,7 @@ test_lock_filter() ...@@ -160,7 +160,7 @@ test_lock_filter()
local type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//') local type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//')
if [ $(grep -c -v "${type}" "${result}") != "0" ]; then if [ $(grep -c -v "${type}" "${result}") != "0" ]; then
echo "[Fail] Recorded should not have non-${type} locks:" $(cat "${result}") echo "[Fail] Recorded result should not have non-${type} locks:" $(cat "${result}")
err=1 err=1
exit exit
fi fi
...@@ -171,7 +171,63 @@ test_lock_filter() ...@@ -171,7 +171,63 @@ test_lock_filter()
perf lock con -a -b -L tasklist_lock -q -- perf bench sched messaging > /dev/null 2> ${result} perf lock con -a -b -L tasklist_lock -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(grep -c -v "${type}" "${result}") != "0" ]; then if [ $(grep -c -v "${type}" "${result}") != "0" ]; then
echo "[Fail] Recorded should not have non-${type} locks:" $(cat "${result}") echo "[Fail] BPF result should not have non-${type} locks:" $(cat "${result}")
err=1
exit
fi
}
test_stack_filter()
{
echo "Testing perf lock contention --callstack-filter (w/ unix_stream)"
perf lock contention -i ${perfdata} -v -q 2> ${result}
if [ $(grep -c unix_stream "${result}") == "0" ]; then
echo "[Skip] Could not find 'unix_stream'"
return
fi
perf lock contention -i ${perfdata} -E 1 -S unix_stream -q 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] Recorded result should have a lock from unix_stream:" $(cat "${result}")
err=1
exit
fi
if ! perf lock con -b true > /dev/null 2>&1 ; then
return
fi
perf lock con -a -b -S unix_stream -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] BPF result should have a lock from unix_stream:" $(cat "${result}")
err=1
exit
fi
}
test_aggr_task_stack_filter()
{
echo "Testing perf lock contention --callstack-filter with task aggregation"
perf lock contention -i ${perfdata} -v -q 2> ${result}
if [ $(grep -c unix_stream "${result}") == "0" ]; then
echo "[Skip] Could not find 'unix_stream'"
return
fi
perf lock contention -i ${perfdata} -t -E 1 -S unix_stream -q 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] Recorded result should have a task from unix_stream:" $(cat "${result}")
err=1
exit
fi
if ! perf lock con -b true > /dev/null 2>&1 ; then
return
fi
perf lock con -a -b -t -S unix_stream -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] BPF result should have a task from unix_stream:" $(cat "${result}")
err=1 err=1
exit exit
fi fi
...@@ -186,5 +242,7 @@ test_aggr_task ...@@ -186,5 +242,7 @@ test_aggr_task
test_aggr_addr test_aggr_addr
test_type_filter test_type_filter
test_lock_filter test_lock_filter
test_stack_filter
test_aggr_task_stack_filter
exit ${err} exit ${err}
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