Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 08/14] perf test: Add summary reporting
Date: Thu, 14 May 2026 16:10:09 +0000	[thread overview]
Message-ID: <20260514161009.CD743C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260513230450.529380-9-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] Test summary is bypassed on error paths, leaking memory and contradicting the commit message.
- [Medium] User-overridden skipped tests are double-counted in the summary statistics.
- [Medium] Async-signal-safety deadlock due to `strbuf_addf` allocations in signal-interrupted paths.
--

commit 6ba5c5902b4731354e1e3209d7b4d55a0a3bc650
Author: Ian Rogers <irogers@google.com>

perf test: Add summary reporting

This commit introduces a global execution summary for perf tests, tracking
pass, skip, and fail counts and printing them at the end of the run. It also
records failed test descriptions into a buffer for easy cross-referencing.

> 4. Invoke the summary printer right before freeing the test array at the
>    absolute tail of __cmd_test(), guaranteeing that the summary is
>    successfully printed even if an internal emergency signal cleanup occurs
>    or if the user interrupts the run early.

Is this description accurate? Looking at __cmd_test(), print_tests_summary()
is placed inside an else block that is bypassed if err is set.

> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index 45c1afb9ad333..193a7dec6d5f3 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -389,6 +400,15 @@ static int print_test_result(struct test_suite *t, int curr_suite, int curr_test
>  		break;
>  	case TEST_FAIL:
>  	default:
> +		summary_tests_failed++;
> +		if (test_suite__num_test_cases(t) > 1)
> +			strbuf_addf(&summary_failed_tests_buf, "  %3d.%1d: %s\n",
> +				    curr_suite + 1, curr_test_case + 1,
> +				    test_description(t, curr_test_case));
> +		else
> +			strbuf_addf(&summary_failed_tests_buf, "  %3d: %s\n",
> +				    curr_suite + 1,
> +				    test_description(t, curr_test_case));
>  		color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");

If a signal interrupts the main thread while it holds the libc heap lock,
could this lead to a deadlock? The cleanup path triggered by the signal
handler calls:

cmd_test_sig_handler() -> siglongjmp() -> finish_test() ->
print_test_result() -> strbuf_addf()

which can invoke realloc() while the heap lock is already held.

[ ... ]

> @@ -1045,6 +1081,7 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],
>  				pr_info("%3d: %-*s:", curr_suite + 1, width,
>  					test_description(*t, -1));
>  				color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
> +				summary_tests_skipped++;
>  				continue;
>  			}

Since this code runs inside the for (int pass = 1; pass <= 2; pass++) loop,
will this increment summary_tests_skipped twice for each user-skipped
test suite?

[ ... ]

> @@ -1076,6 +1113,8 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],
>  		pr_err("Internal test harness failure. Completing any started tests:\n:");
>  		for (size_t x = 0; x < num_tests; x++)
>  			finish_test(child_tests, x, num_tests, width);
> +	} else {
> +		print_tests_summary();
>  	}
>  	free(child_tests);
>  	return err;

Since print_tests_summary() is only called in the else branch, does this
leak summary_failed_tests_buf when err is non-zero (for instance, when
handling an internal emergency signal cleanup)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513230450.529380-1-irogers@google.com?part=8

  reply	other threads:[~2026-05-14 16:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 23:04 [PATCH v1 00/14] perf test: Harness improvements Ian Rogers
2026-05-13 23:04 ` [PATCH v1 01/14] perf jevents.py: Make generated C code more kernel style Ian Rogers
2026-05-13 23:04 ` [PATCH v1 02/14] perf pmu-events: Add API to get metric table name and iterate tables Ian Rogers
2026-05-14 11:42   ` sashiko-bot
2026-05-13 23:04 ` [PATCH v1 03/14] perf test: Drain pipe after child finishes to avoid losing output Ian Rogers
2026-05-13 23:04 ` [PATCH v1 04/14] perf test: Support dynamic test suites with setup callback and private data Ian Rogers
2026-05-14 12:10   ` sashiko-bot
2026-05-13 23:04 ` [PATCH v1 05/14] perf test pmu-events: A sub-test per metric table Ian Rogers
2026-05-13 23:04 ` [PATCH v1 06/14] perf test: Refactor parallel poll loop to drain all pipes simultaneously Ian Rogers
2026-05-14 14:27   ` sashiko-bot
2026-05-13 23:04 ` [PATCH v1 07/14] perf test: Show snippet failure output for verbose=1 Ian Rogers
2026-05-14 15:50   ` sashiko-bot
2026-05-13 23:04 ` [PATCH v1 08/14] perf test: Add summary reporting Ian Rogers
2026-05-14 16:10   ` sashiko-bot [this message]
2026-05-13 23:04 ` [PATCH v1 09/14] perf test: Fix subtest status alignment for multi-digit indexes Ian Rogers
2026-05-13 23:04 ` [PATCH v1 10/14] perf test: Skip shebang and SPDX comments in shell test descriptions Ian Rogers
2026-05-13 23:04 ` [PATCH v1 11/14] perf test: Split monolithic 'util' test suite into sub-tests Ian Rogers
2026-05-13 23:04 ` [PATCH v1 12/14] perf test: Add -j/--junit option for JUnit XML test reports Ian Rogers
2026-05-14 17:48   ` sashiko-bot
2026-05-13 23:04 ` [PATCH v1 13/14] perf test: Add shell test to validate JUnit XML reporting output Ian Rogers
2026-05-13 23:04 ` [PATCH v1 14/14] perf test: Remove /usr/bin/cc dependency from Intel PT shell test Ian Rogers
2026-05-14 18:28   ` sashiko-bot

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=20260514161009.CD743C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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