From: Jiebin Sun <jiebin.sun@intel.com>
To: namhyung@kernel.org
Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org,
adrian.hunter@intel.com, alexander.shishkin@linux.intel.com,
irogers@google.com, james.clark@linaro.org, jolsa@kernel.org,
mark.rutland@arm.com, dapeng1.mi@linux.intel.com,
thomas.falcon@intel.com, tianyou.li@intel.com,
wangyang.guo@intel.com, jiebin.sun@intel.com,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] perf tests c2c: Add function view stdio coverage
Date: Fri, 21 Aug 2026 13:56:11 +0800 [thread overview]
Message-ID: <9bd7a313c9c1d71058e857c320c6d5c30cf4cbfa.1787283281.git.jiebin.sun@intel.com> (raw)
In-Reply-To: <cover.1787283281.git.jiebin.sun@intel.com>
Exercise the function view without driving a terminal now that it has
a stdio path. Keep the existing datasym record/report coverage and make a
separate recording of the contended locks used by the futex hash benchmark.
Always check the function table headers, table replacement, missing-iaddr
diagnostic, and conflicting options. A machine can support c2c recording
without capturing a contended sample, so report a skip when the hierarchy
is empty rather than treating hardware sampling variance as a failure.
When samples are available, check generic row shapes for all three
hierarchy levels, their expanded fold signs, cacheline addresses, and the
absence of trailing whitespace in the table body.
Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Reviewed-by: Tianyou Li <tianyou.li@intel.com>
Reviewed-by: Wangyang Guo <wangyang.guo@intel.com>
---
tools/perf/tests/shell/c2c.sh | 113 ++++++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
diff --git a/tools/perf/tests/shell/c2c.sh b/tools/perf/tests/shell/c2c.sh
index f5f223cbf9cc..cf76359d19cc 100755
--- a/tools/perf/tests/shell/c2c.sh
+++ b/tools/perf/tests/shell/c2c.sh
@@ -6,10 +6,15 @@ set -e
err=0
perfdata=$(mktemp /tmp/__perf_c2c_test.perf.data.XXXXX)
+funcdata=$(mktemp /tmp/__perf_c2c_function_test.perf.data.XXXXX)
+perfout=$(mktemp /tmp/__perf_c2c_test.output.XXXXX)
cleanup() {
rm -f "${perfdata}"
rm -f "${perfdata}".old
+ rm -f "${funcdata}"
+ rm -f "${funcdata}".old
+ rm -f "${perfout}"
trap - EXIT TERM INT
}
@@ -58,6 +63,114 @@ test_c2c_record_report() {
echo "c2c record and report test [Success]"
}
+test_c2c_function_report() {
+ echo "c2c function stdio report test"
+
+ if perf c2c report -i "${perfdata}" --function -c pid > "${perfout}" 2>&1 ; then
+ echo "c2c function stdio report test [Failed: report accepted missing iaddr]"
+ err=1
+ return
+ fi
+ if ! grep -Fq "The function view requires iaddr in --coalesce." "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: missing iaddr diagnostic]"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+ if grep -Fq "Shared Data Functions Table" "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: partial report on missing iaddr]"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+
+ if perf c2c report -i "${perfdata}" --function --stats > "${perfout}" 2>&1 ; then
+ echo "c2c function stdio report test [Failed: accepted conflicting options]"
+ err=1
+ return
+ fi
+ if ! grep -Fq -- "--stats and --function cannot be used together." "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: missing conflict diagnostic]"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+
+ # Exercise contended futex hash-bucket locks so the function view can get
+ # reader, writer, and cacheline rows without changing the original test.
+ if ! perf c2c record -o "${funcdata}" -- \
+ perf bench futex hash -t 4 -r 1 -s > /dev/null 2>&1 ; then
+ echo "c2c function stdio report test [Skipped: recording failed]"
+ err=2
+ return
+ fi
+
+ if ! perf c2c report -i "${funcdata}" --function > "${perfout}" 2>&1 ; then
+ echo "c2c function stdio report test [Failed: report failed]"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+
+ for expected in "Shared Data Functions Table" \
+ "# Cycles Store" \
+ "# % count Function / Contending function / Cacheline" \
+ "# ......... ......." ; do
+ if ! grep -Fq "${expected}" "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: missing '${expected}']"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+ done
+ for unexpected in "Shared Data Cache Line Table" \
+ "Shared Cache Line Distribution Pareto" ; do
+ if grep -Fq "${unexpected}" "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: found '${unexpected}']"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+ done
+
+ if ! awk '/^# \.+/ { body = 1; next }
+ body && !/^#/ && NF { found = 1 }
+ END { exit !found }' "${perfout}" ; then
+ echo "c2c function stdio report test [Skipped: no contended samples]"
+ err=2
+ return
+ fi
+
+ # The spaces intentionally verify per-level indentation and expanded
+ # fold-sign placement without depending on symbol names.
+ for expected in \
+ '^ - +[0-9]+\.[0-9]+% +[0-9]+ - ' \
+ '^ +[0-9]+ - ' \
+ '^ +[0-9]+ 0x[[:xdigit:]]+$' ; do
+ if ! grep -Eq "${expected}" "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: missing hierarchy row]"
+ echo " ${expected}"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+ done
+
+ if awk '/^# \.+/ { body = 1; next }
+ body && /[[:blank:]]$/ { found = 1 }
+ END { exit !found }' "${perfout}" ; then
+ echo "c2c function stdio report test [Failed: trailing whitespace in table body]"
+ cat "${perfout}"
+ err=1
+ return
+ fi
+
+ echo "c2c function stdio report test [Success]"
+}
+
test_c2c_record_report
+if [ "${err}" -eq 0 ]; then
+ test_c2c_function_report
+fi
cleanup
exit $err
--
2.52.0
next prev parent reply other threads:[~2026-08-21 5:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 5:56 [PATCH 0/4] perf c2c: Add function-view stdio support and coverage Jiebin Sun
2026-08-21 5:56 ` [PATCH 1/4] perf c2c: Fix documented default coalesce fields Jiebin Sun
2026-08-21 5:56 ` [PATCH 2/4] perf tests c2c: Report skip when the workload fails Jiebin Sun
2026-08-21 5:56 ` [PATCH 3/4] perf c2c: Add stdio support for the function view Jiebin Sun
2026-08-21 5:56 ` Jiebin Sun [this message]
2026-08-29 20:05 ` [PATCH 0/4] perf c2c: Add function-view stdio support and coverage Namhyung Kim
2026-08-29 22:51 ` Arnaldo 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=9bd7a313c9c1d71058e857c320c6d5c30cf4cbfa.1787283281.git.jiebin.sun@intel.com \
--to=jiebin.sun@intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=tianyou.li@intel.com \
--cc=wangyang.guo@intel.com \
/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
all inboxes | Powered by JetHome®