From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-perf-users@vger.kernel.org, Song Liu <song@kernel.org>,
Blake Jones <blakejones@google.com>,
bpf@vger.kernel.org
Subject: [PATCH 6/6] perf test: Update perf lock contention test
Date: Mon, 19 Dec 2022 12:17:32 -0800 [thread overview]
Message-ID: <20221219201732.460111-7-namhyung@kernel.org> (raw)
In-Reply-To: <20221219201732.460111-1-namhyung@kernel.org>
Add more tests for the new filters.
$ sudo perf test contention -v
87: kernel lock contention analysis test :
--- start ---
test child forked, pid 412379
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
Testing perf lock contention --lock-filter
test child finished with 0
---- end ----
kernel lock contention analysis test: Ok
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/lock_contention.sh | 58 ++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/lock_contention.sh b/tools/perf/tests/shell/lock_contention.sh
index cc9ceb9e19ca..b05f1b1ca6c8 100755
--- a/tools/perf/tests/shell/lock_contention.sh
+++ b/tools/perf/tests/shell/lock_contention.sh
@@ -115,7 +115,7 @@ test_aggr_addr()
fi
# the perf lock contention output goes to the stderr
- perf lock con -a -b -t -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
+ perf lock con -a -b -l -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] BPF result count is not 1:" $(cat "${result}" | wc -l)
err=1
@@ -123,6 +123,60 @@ test_aggr_addr()
fi
}
+test_type_filter()
+{
+ echo "Testing perf lock contention --type-filter (w/ spinlock)"
+ perf lock contention -i ${perfdata} -Y spinlock -q 2> ${result}
+ if [ $(grep -c -v spinlock "${result}") != "0" ]; then
+ echo "[Fail] Recorded should not have non-spinlocks:" $(cat "${result}")
+ err=1
+ exit
+ fi
+
+ if ! perf lock con -b true > /dev/null 2>&1 ; then
+ return
+ fi
+
+ perf lock con -a -b -Y spinlock -q -- perf bench sched messaging > /dev/null 2> ${result}
+ if [ $(grep -c -v spinlock "${result}") != "0" ]; then
+ echo "[Fail] Recorded should not have non-spinlocks:" $(cat "${result}")
+ err=1
+ exit
+ fi
+}
+
+test_lock_filter()
+{
+ echo "Testing perf lock contention --lock-filter (w/ tasklist_lock)"
+ perf lock contention -i ${perfdata} -l -q 2> ${result}
+ if [ $(grep -c tasklist_lock "${result}") != "1" ]; then
+ echo "[Skip] Could not find 'tasklist_lock'"
+ return
+ fi
+
+ perf lock contention -i ${perfdata} -L tasklist_lock -q 2> ${result}
+
+ # find out the type of tasklist_lock
+ local type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//')
+
+ if [ $(grep -c -v "${type}" "${result}") != "0" ]; then
+ echo "[Fail] Recorded should not have non-${type} locks:" $(cat "${result}")
+ err=1
+ exit
+ fi
+
+ if ! perf lock con -b true > /dev/null 2>&1 ; then
+ return
+ fi
+
+ 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
+ echo "[Fail] Recorded should not have non-${type} locks:" $(cat "${result}")
+ err=1
+ exit
+ fi
+}
+
check
test_record
@@ -130,5 +184,7 @@ test_bpf
test_record_concurrent
test_aggr_task
test_aggr_addr
+test_type_filter
+test_lock_filter
exit ${err}
--
2.39.0.314.g84b9a713c41-goog
next prev parent reply other threads:[~2022-12-19 20:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 20:17 [PATCH 0/6] perf lock contention: Add more filter options (v1) Namhyung Kim
2022-12-19 20:17 ` [PATCH 1/6] perf lock contention: Factor out lock_type_table Namhyung Kim
2022-12-19 20:17 ` [PATCH 2/6] perf lock contention: Add -Y/--type-filter option Namhyung Kim
2022-12-21 17:50 ` Arnaldo Carvalho de Melo
2022-12-21 17:54 ` Namhyung Kim
2022-12-19 20:17 ` [PATCH 3/6] perf lock contention: Support lock type filtering for BPF Namhyung Kim
2022-12-19 20:17 ` [PATCH 4/6] perf lock contention: Add -L/--lock-filter option Namhyung Kim
2022-12-19 20:17 ` [PATCH 5/6] perf lock contention: Support lock addr/name filtering for BPF Namhyung Kim
2022-12-19 20:17 ` Namhyung Kim [this message]
2022-12-20 18:28 ` [PATCH 0/6] perf lock contention: Add more filter options (v1) Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221219201732.460111-7-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=blakejones@google.com \
--cc=bpf@vger.kernel.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).