Skip to contentSkip to conversation

perf c2c: Add function-view stdio support and coverage

PATCH In review Jiebin Sun 5 participants 14 messages Aug 21 – Sep 25 perf events

lore
Share & tools
lore

Jiebin Sun

author
#0 lore raw

cover perf c2c: Add function-view stdio support and coverage

The recently merged function-view series added an interactive TUI for examining the c2c data as:

read-side function -> contending writer -> shared cacheline

This follow-up makes the same view available to builds without SLANG and to pipes and scripts. perf c2c report --function now implies stdio and prints the three-level hierarchy fully expanded. It requires iaddr in the coalescing fields and is rejected together with --stats.

The first two patches fix adjacent pre-existing issues: the documented default coalesce fields are stale, and a workload recording failure in the existing c2c shell test is incorrectly reported as a pass. The third patch adds the stdio function view, and the final patch adds automated coverage using a separate contended futex workload. Systems that record no contended samples report a skip for the hierarchy checks rather than a spurious failure.

This series follows the function-view work merged from:

https://lore.kernel.org/linux-perf-users/[email protected]/

The series is based on perf-tools-next commit 9453bc6a69ef ("perf vendor events arm64: Fix Tegra410 Olympus event 0x0197").

Tested with:

- SLANG and NO_SLANG=1 builds
- perf test c2c
- perf test 'import perf'
- checkpatch.pl --strict on each patch
- unresolved-symbol checks on the Python perf module

Jiebin Sun (4):
perf c2c: Fix documented default coalesce fields perf tests c2c: Report skip when the workload fails perf c2c: Add stdio support for the function view perf tests c2c: Add function view stdio coverage

 tools/perf/Documentation/perf-c2c.txt |  14 +++-
 tools/perf/builtin-c2c.c              |  85 +++++++++++++++++--
 tools/perf/tests/shell/c2c.sh         | 114 ++++++++++++++++++++++++++
 tools/perf/util/c2c-function.c        |   9 +-
 tools/perf/util/c2c.h                 |   1 +
 5 files changed, 205 insertions(+), 18 deletions(-)

base-commit: 9453bc6a69ef43755f1c28d5688cacdd69fa16bd

Signature · 1 line
2.52.0
author
#1 lore raw

PATCH 1/4 perf c2c: Fix documented default coalesce fields

The default coalesce fields dropped pid in favor of iaddr, but the man page still documents the old pid,iaddr default. Update it to match the command.

Fixes 423701a0c8d7 ("perf c2c: Change the default coalesce setup")
Cc Dapeng Mi <[email protected]>
Cc Ian Rogers <[email protected]>
Cc James Clark <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Thomas Falcon <[email protected]>
---
 tools/perf/Documentation/perf-c2c.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Documentation/perf-c2c.txt +1 -1
index 8775889bc0a3..9e58a51c55de 100644
@@ -341,7 +341,7 @@ output fields set for cacheline offsets output:
              Code address, Code symbol, Shared Object, Source line
   dso   - coalesced by shared object
 
-By default the coalescing is setup with 'pid,iaddr'.
+By default, coalescing uses `iaddr`.
 
 STDIO OUTPUT
 ------------
Signature · 1 line
2.52.0
author
#3 lore raw

PATCH 2/4 perf tests c2c: Report skip when the workload fails

In reply to Jiebin Sun

The workload path leaves err at 0 and returns, so the test exits 0 and is reported as a pass even though nothing was recorded and neither report invocation ran. The check_c2c_support() path above it already sets err=2.

Set err=2 there as well so a failing workload is reported as a skip.

Fixes ac881007c4bf ("perf tests c2c: Add a basic c2c")
Cc Dapeng Mi <[email protected]>
Cc Ian Rogers <[email protected]>
Cc James Clark <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Thomas Falcon <[email protected]>
---
 tools/perf/tests/shell/c2c.sh | 1 +
 1 file changed, 1 insertion(+)
tools/perf/tests/shell/c2c.sh +1 -0
index 2471d44595c3..f5f223cbf9cc 100755
@@ -39,6 +39,7 @@ test_c2c_record_report() {
 	# Run a workload that does some memory operations.
 	if ! perf c2c record -o "${perfdata}" -- perf test -w datasym 1 > /dev/null 2>&1 ; then
 		echo "c2c record and report test [Skipped: perf c2c record failed during workload]"
+		err=2
 		return
 	fi
 
Signature · 1 line
2.52.0
author
#5 lore raw

PATCH 3/4 perf c2c: Add stdio support for the function view

In reply to Jiebin Sun

The function view is currently TUI-only, so it cannot be used by builds without SLANG support, when output is piped, or from a script. Add a --function option that prints the fully expanded three-level hierarchy to stdout.

Keep the stdio renderer in builtin-c2c.c and reuse the common function-view model introduced by the merged series. Export only the coalescing-field capability check from the model, preserving the util/UI boundary and leaving the TUI object in libperf-ui.a.

Stop padding the final identity column in symbol_view_entry(). The generic formatter pads non-final columns but deliberately leaves the final column unpadded, avoiding trailing whitespace in function-view table rows. The TUI remains unchanged because its browser clears the rest of each rendered row.

--function implies --stdio and is rejected together with --stats. Validate the iaddr requirement before processing events. Return function-view build failures from the report command, and preserve TUI browser errors when converting the display helpers to return a status.

---
 tools/perf/Documentation/perf-c2c.txt | 12 +++-
 tools/perf/builtin-c2c.c              | 85 ++++++++++++++++++++++++---
 tools/perf/util/c2c-function.c        |  9 +--
 tools/perf/util/c2c.h                 |  1 +
 4 files changed, 90 insertions(+), 17 deletions(-)
tools/perf/Documentation/perf-c2c.txt +10 -2
index 9e58a51c55de..7a0cf31be7ed 100644
@@ -107,6 +107,10 @@ REPORT OPTIONS
 --stats::
 	Display only statistic tables and force stdio mode.
 
+--function::
+	Display the function view and force stdio mode.  This requires `iaddr`
+	in the cacheline coalescing fields and cannot be used with `--stats`.
+
 --full-symbols::
 	Display full length of symbols.
 
@@ -360,6 +364,10 @@ Following tables are displayed:
   Shared Cache Line Distribution Pareto
   - list of all accessed offsets for each cacheline
 
+With `--function`, the cacheline and Pareto tables are replaced by a fully
+expanded Shared Data Functions Table.  Its three levels are the read-side
+function, contending writer, and shared cacheline, as detailed below.
+
 TUI OUTPUT
 ----------
 The TUI output provides interactive interface to navigate
@@ -374,8 +382,8 @@ Verbose mode also includes code addresses in function rows, and code addresses
 remain available in the per-cacheline detail view ('d').
 
 The function view requires `iaddr` in the cacheline coalescing fields.  If
-`--coalesce` omits it, TAB reports that the view is unavailable rather than
-attributing already-coalesced samples to an arbitrary function.
+`--coalesce` omits it, TAB or `--function` reports that the view is unavailable
+rather than attributing already-coalesced samples to an arbitrary function.
 
   Level 1: the read-side function, sorted by Cycles % (estimated load
            cycles: HITM, peer-snoop and other-load cycles)
tools/perf/builtin-c2c.c +76 -9

151 lines not on this page · raw message

tools/perf/util/c2c-function.c +3 -6
index 5b6a06a5a067..d410196d0429 100644
@@ -305,8 +305,8 @@ symbol_view_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 		char symbuf[32];
 
 		scnprintf(symbuf, sizeof(symbuf), "0x%" PRIx64, addr);
-		ret += scnprintf(hpp->buf + ret, hpp->size - ret, "%-*.*s",
-				 text_width, text_width, symbuf);
+		ret += scnprintf(hpp->buf + ret, hpp->size - ret, "%.*s",
+				 text_width, symbuf);
 	} else {
 		/* Level 1 and level 2 are both functions. */
 		size_t cell_size;
@@ -331,9 +331,6 @@ symbol_view_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 			len = min_t(size_t, len, cell_size - 1);
 
 		ret += len;
-		if (len < text_width)
-			ret += scnprintf(hpp->buf + ret, hpp->size - ret, "%*s",
-					 text_width - len, "");
 	}
 
 	return ret;
@@ -1519,7 +1516,7 @@ void c2c_function__reset(void)
 	symbol_conf.use_callchain = saved_use_callchain;
 }
 
-static bool c2c_function__has_iaddr(const char *cl_sort)
+bool c2c_function__has_iaddr(const char *cl_sort)
 {
 	const char *field = cl_sort;
 
tools/perf/util/c2c.h +1 -0
index 53f024e25d99..198032ec7c87 100644
@@ -107,6 +107,7 @@ bool c2c_fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
 int c2c_function__build(struct c2c_hists *cl_hists, const char *cl_sort,
 			bool symbol_full, struct hists **hists);
 void c2c_function__reset(void);
+bool c2c_function__has_iaddr(const char *cl_sort);
 /* Valid only between a successful build and c2c_function__reset(). */
 struct hist_entry *c2c_function__find_cacheline(struct hist_entry *he);
 
Signature · 1 line
2.52.0
author
#7 lore raw

PATCH 4/4 perf tests c2c: Add function view stdio coverage

In reply to Jiebin Sun

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.

---
 tools/perf/tests/shell/c2c.sh | 113 ++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)
tools/perf/tests/shell/c2c.sh +113 -0
index f5f223cbf9cc..cf76359d19cc 100755
@@ -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
Signature · 1 line
2.52.0
#4 lore raw

Re: [PATCH 2/4] perf tests c2c: Report skip when the workload fails

In reply to Jiebin Sun
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

The workload path leaves err at 0 and returns, so the test exits 0 and is reported as a pass even though nothing was recorded and neither report invocation ran. The check_c2c_support() path above it already sets err=2.

Set err=2 there as well so a failing workload is reported as a skip.

Fixes ac881007c4bf ("perf tests c2c: Add a basic c2c")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#2 lore raw

Re: [PATCH 1/4] perf c2c: Fix documented default coalesce fields

In reply to Jiebin Sun
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines

The default coalesce fields dropped pid in favor of iaddr, but the man page still documents the old pid,iaddr default. Update it to match the command.

Fixes 423701a0c8d7 ("perf c2c: Change the default coalesce setup")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#8 lore raw

Re: [PATCH 4/4] perf tests c2c: Add function view stdio coverage

In reply to Jiebin Sun
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The newly added `test_c2c_function_report` test fails spuriously because it incorrectly assumes…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly added test_c2c_function_report test fails spuriously because it incorrectly assumes perfdata is valid when err is 0. If the workload in test_c2c_record_report fails, it returns early but leaves err=0. This causes test_c2c_function_report to process an invalid or missing perfdata file, failing its diagnostic checks and setting err=1 (test failure). --

--- Patch [4]: [PATCH 4/4] perf tests c2c: Add function view stdio coverage --- commit 32c977aa30c2c6186f39077056298ef3b53307dd
Author: Jiebin Sun <[email protected]>

perf tests c2c: Add function view stdio coverage

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.

Quoted 4 lines
tools/perf/tests/shell/c2c.sh +0 -0
index f5f223cbf9cc7..cf76359d19ccd 100755

[ ... ]

Quoted 12 lines
tools/perf/tests/shell/c2c.sh +8 -0
@@ -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

[ ... ]

tools/perf/tests/shell/c2c.sh test_c2c_record_report() { · line 176

Quoted 6 lines

test_c2c_record_report

tools/perf/tests/shell/c2c.sh +3 -0
+if [ "${err}" -eq 0 ]; then
+	test_c2c_function_report
+fi
 cleanup
 exit $err

[Severity: Medium]
Will this lead to a spurious test failure if the record workload fails?

In test_c2c_record_report(), if the 'perf test -w datasym 1' workload fails, it returns early without modifying err, leaving err=0:

	if ! perf c2c record -o "${perfdata}" -- perf test -w datasym 1 > /dev/null 2>&1 ; then
		echo "c2c record and report test [Skipped: perf c2c record failed during workload]"
		return
	fi

Because err remains 0, test_c2c_function_report() will conditionally execute and attempt to use the missing or invalid perfdata file. This will cause test_c2c_function_report() to fail its diagnostic checks and set err=1.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#6 lore raw

Re: [PATCH 3/4] perf c2c: Add stdio support for the function view

In reply to Jiebin Sun
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Medium] Memory leak: L2 and L3 function-view child entries are not freed on cleanup because perf c2c does not set symbol_conf.report_hierarchy, bypassing the recursive deletion in hist_entry__delete(). --

--- Patch [3]: [PATCH 3/4] perf c2c: Add stdio support for the function view --- commit e1f0ed49bafb9da749fbfa14e02ab8497ae9d5d4
Author: Jiebin Sun <[email protected]>

perf c2c: Add stdio support for the function view

This commit adds a --function option to perf c2c to print the fully expanded three-level hierarchy to stdout, allowing its use without SLANG support, when piped, or in scripts. It reuses the common function-view model while preserving the boundary between utilities and the UI.

Quoted 3 lines
tools/perf/util/c2c-function.c +0 -0

[ ... ]

tools/perf/util/c2c-function.c void c2c_function__reset(void) · line 1517

Quoted 3 lines
tools/perf/util/c2c-function.c +0 -0
@@ -1519,7 +1516,7 @@ void c2c_function__reset(void)
 	symbol_conf.use_callchain = saved_use_callchain;
 }

[Severity: Medium]
This is a pre-existing issue, but does this teardown logic in c2c_function__reset() leak the L2 and L3 function-view child entries?

When cleaning up the hierarchy, hists__delete_all_entries() relies on hist_entry__delete() for each node. However, in tools/perf/util/hist.c, hist_entry__delete() only recursively deletes the child entries in hroot_out if the hierarchy flag is set:

tools/perf/util/hist.c:hist_entry__delete() {
    ...
    if (symbol_conf.report_hierarchy) {
        struct rb_root *root = &he->hroot_out.rb_root;
        struct hist_entry *child, *tmp;

        rbtree_postorder_for_each_entry_safe(child, tmp, root, rb_node)
            hist_entry__delete(child);

        *root = RB_ROOT;
    }
    ...
}

Since perf c2c does not appear to set symbol_conf.report_hierarchy, won't these child entries be orphaned and skipped during cleanup?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
maintainer Acked-by on the v1 series
#12 lore raw
In reply to Jiebin Sun

Hello,

Quoted 33 lines · Jiebin Sun

The recently merged function-view series added an interactive TUI for examining the c2c data as:

read-side function -> contending writer -> shared cacheline

This follow-up makes the same view available to builds without SLANG and to pipes and scripts. perf c2c report --function now implies stdio and prints the three-level hierarchy fully expanded. It requires iaddr in the coalescing fields and is rejected together with --stats.

The first two patches fix adjacent pre-existing issues: the documented default coalesce fields are stale, and a workload recording failure in the existing c2c shell test is incorrectly reported as a pass. The third patch adds the stdio function view, and the final patch adds automated coverage using a separate contended futex workload. Systems that record no contended samples report a skip for the hierarchy checks rather than a spurious failure.

This series follows the function-view work merged from:

https://lore.kernel.org/linux-perf-users/[email protected]/

The series is based on perf-tools-next commit 9453bc6a69ef ("perf vendor events arm64: Fix Tegra410 Olympus event 0x0197").

Tested with:

- SLANG and NO_SLANG=1 builds
- perf test c2c
- perf test 'import perf'
- checkpatch.pl --strict on each patch
- unresolved-symbol checks on the Python perf module

Quoted 5 lines

Jiebin Sun (4):
perf c2c: Fix documented default coalesce fields perf tests c2c: Report skip when the workload fails perf c2c: Add stdio support for the function view perf tests c2c: Add function view stdio coverage

Thanks for doing this!

Thanks,
Namhyung

Quoted 12 lines
 tools/perf/Documentation/perf-c2c.txt |  14 +++-
 tools/perf/builtin-c2c.c              |  85 +++++++++++++++++--
 tools/perf/tests/shell/c2c.sh         | 114 ++++++++++++++++++++++++++
 tools/perf/util/c2c-function.c        |   9 +-
 tools/perf/util/c2c.h                 |   1 +
 5 files changed, 205 insertions(+), 18 deletions(-)

base-commit: 9453bc6a69ef43755f1c28d5688cacdd69fa16bd

Signature · 1 line
2.52.0
#13 lore raw
Quoted 42 lines · Namhyung Kim

Hello,

Quoted 33 lines · Jiebin Sun

The recently merged function-view series added an interactive TUI for examining the c2c data as:

read-side function -> contending writer -> shared cacheline

This follow-up makes the same view available to builds without SLANG and to pipes and scripts. perf c2c report --function now implies stdio and prints the three-level hierarchy fully expanded. It requires iaddr in the coalescing fields and is rejected together with --stats.

The first two patches fix adjacent pre-existing issues: the documented default coalesce fields are stale, and a workload recording failure in the existing c2c shell test is incorrectly reported as a pass. The third patch adds the stdio function view, and the final patch adds automated coverage using a separate contended futex workload. Systems that record no contended samples report a skip for the hierarchy checks rather than a spurious failure.

This series follows the function-view work merged from:

https://lore.kernel.org/linux-perf-users/[email protected]/

The series is based on perf-tools-next commit 9453bc6a69ef ("perf vendor events arm64: Fix Tegra410 Olympus event 0x0197").

Tested with:

- SLANG and NO_SLANG=1 builds
- perf test c2c
- perf test 'import perf'
- checkpatch.pl --strict on each patch
- unresolved-symbol checks on the Python perf module

Quoted 5 lines

Jiebin Sun (4):
perf c2c: Fix documented default coalesce fields perf tests c2c: Report skip when the workload fails perf c2c: Add stdio support for the function view perf tests c2c: Add function view stdio coverage

Quoted 3 lines

Thanks for doing this!

Thanks, I'll try and process this RSN so that the other patchset that Namhyung mentioned may conflict this can be rebased.

- Arnaldo

- Arnaldo

Quoted 16 lines

Thanks,
Namhyung

Quoted 12 lines
 tools/perf/Documentation/perf-c2c.txt |  14 +++-
 tools/perf/builtin-c2c.c              |  85 +++++++++++++++++--
 tools/perf/tests/shell/c2c.sh         | 114 ++++++++++++++++++++++++++
 tools/perf/util/c2c-function.c        |   9 +-
 tools/perf/util/c2c.h                 |   1 +
 5 files changed, 205 insertions(+), 18 deletions(-)

base-commit: 9453bc6a69ef43755f1c28d5688cacdd69fa16bd

Signature · 1 line
2.52.0

- Arnaldo

#9 lore raw

Re: [PATCH 4/4] perf tests c2c: Add function view stdio coverage

In reply to [email protected]
Quoted 3 lines · On Fri, Aug 21, 2026 at 05:58:03AM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly added test_c2c_function_report test fails spuriously because it incorrectly assumes perfdata is valid when err is 0. If the workload in test_c2c_record_report fails, it returns early but leaves err=0. This causes test_c2c_function_report to process an invalid or missing perfdata file, failing its diagnostic checks and setting err=1 (test failure). --

Can you please take a look at this one? Namhyung Acked the series and the other patches are clean so after this gets addressed I'll merge it.

Thanks,

- Arnaldo

Quoted 52 lines

--- Patch [4]: [PATCH 4/4] perf tests c2c: Add function view stdio coverage --- commit 32c977aa30c2c6186f39077056298ef3b53307dd
Author: Jiebin Sun <[email protected]>

perf tests c2c: Add function view stdio coverage

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.

Quoted 4 lines
tools/perf/tests/shell/c2c.sh +0 -0
index f5f223cbf9cc7..cf76359d19ccd 100755

[ ... ]

Quoted 12 lines
tools/perf/tests/shell/c2c.sh +8 -0
@@ -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

[ ... ]

tools/perf/tests/shell/c2c.sh test_c2c_record_report() { · line 176

Quoted 6 lines

test_c2c_record_report

tools/perf/tests/shell/c2c.sh +3 -0
+if [ "${err}" -eq 0 ]; then
+	test_c2c_function_report
+fi
 cleanup
 exit $err

[Severity: Medium]
Will this lead to a spurious test failure if the record workload fails?

In test_c2c_record_report(), if the 'perf test -w datasym 1' workload fails, it returns early without modifying err, leaving err=0:

	if ! perf c2c record -o "${perfdata}" -- perf test -w datasym 1 > /dev/null 2>&1 ; then
		echo "c2c record and report test [Skipped: perf c2c record failed during workload]"
		return
	fi

Because err remains 0, test_c2c_function_report() will conditionally execute and attempt to use the missing or invalid perfdata file. This will cause test_c2c_function_report() to fail its diagnostic checks and set err=1.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author
#10 lore raw

Re: [PATCH 4/4] perf tests c2c: Add function view stdio coverage

Hi Arnaldo,

Thanks for checking this.

Patch 2/4 covers this case:

perf tests c2c: Report skip when the workload fails

It sets err=2 before returning when the workload fails, while patch 4 calls test_c2c_function_report() only when err remains 0.

I also verified this by forcing the workload command to fail. The script printed the skip message, did not run the function test, and exited with status 2, which the perf test harness treats as a skip.

So I don't think any change is needed here.

Thanks,
Jiebin

#11 lore raw

Re: [PATCH 4/4] perf tests c2c: Add function view stdio coverage

Quoted 8 lines · Jiebin Sun

Hi Arnaldo,

Thanks for checking this.

Patch 2/4 covers this case:

perf tests c2c: Report skip when the workload fails

Quoted 8 lines

It sets err=2 before returning when the workload fails, while patch 4 calls test_c2c_function_report() only when err remains 0.

I also verified this by forcing the workload command to fail. The script printed the skip message, did not run the function test, and exited with status 2, which the perf test harness treats as a skip.

So I don't think any change is needed here.

Thanks for checking, applied to perf-tools-next, for v7.4.

- Arnaldo