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 v5 2/2] perf arch x86 tests: Add test for topdown event sorting
Date: Mon, 18 May 2026 01:20:40 +0000	[thread overview]
Message-ID: <20260518012040.DDA4DC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260518003704.2434308-3-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The validation block for `expected_instructions_group_size == 2` in `test_sort()` is structurally unreachable dead code.
- [Low] Passing `test_sort()` directly to `TEST_ASSERT_EQUAL` causes the test function to execute twice upon failure.
--

commit 418562cab64daaf4f2d774b19e333bea0ea7f81a
Author: Ian Rogers <irogers@google.com>

perf arch x86 tests: Add test for topdown event sorting

This commit adds a test to verify that slots and topdown-retiring get
appropriately sorted with respect to instructions when specified together. It
also adds a related test to ensure the slots event is injected into the
appropriate group when not explicitly provided.

> diff --git a/tools/perf/arch/x86/tests/topdown.c b/tools/perf/arch/x86/tests/topdown.c
> index 3ee4e5e71be3b..9e9dbea7998dc 100644
> --- a/tools/perf/arch/x86/tests/topdown.c
> +++ b/tools/perf/arch/x86/tests/topdown.c
[ ... ]
> +	evlist__for_each_entry(evlist, evsel) {
> +		if (!evsel__is_group_leader(evsel))
> +			continue;
[ ... ]
> +		} else if (strstr(evsel__name(evsel), "instructions")) {
> +			CHECK_EQUAL(evsel->core.nr_members, expected_instructions_group_size,
> +				    "instructions group size");
> +			if (expected_instructions_group_size == 2) {
> +				/*
> +				 * The instructions event leads a group with a
> +				 * topdown-retiring event, neither of which need
> +				 * reordering for perf metric event support.
> +				 */
> +				struct evsel *next = evsel__next(evsel);
> +
> +				CHECK_COND(strstr(evsel__name(next), "topdown-retiring") != NULL,
> +					   "instructions second event is topdown-retiring");
> +			}

Is this validation block for expected_instructions_group_size == 2 reachable?

The loop explicitly skips events that are not group leaders at the top.
However, in the test cases passing 2 for expected_instructions_group_size,
the slots event is injected as the group leader for all three events.

Consequently, instructions becomes a subordinate group member and is skipped
by the loop entirely, which bypasses these test assertions.

[ ... ]
> +static int test__x86_topdown_sorting(struct test_suite *test __maybe_unused,
> +				     int subtest __maybe_unused)
> +{
> +	if (!topdown_sys_has_perf_metrics())
> +		return TEST_OK;
> +
> +	TEST_ASSERT_EQUAL("all events in a group",
> +			  test_sort("{instructions,topdown-retiring,slots}", 3, 2), TEST_OK);

Does passing test_sort() directly to TEST_ASSERT_EQUAL cause the test to
execute twice upon failure?

The TEST_ASSERT_EQUAL macro in tools/perf/tests/tests.h evaluates the
provided value a second time in its pr_debug statement if the assertion
fails.

Since test_sort() allocates an evlist, parses events, and prints internal
debug logs, evaluating it twice creates duplicate work and duplicate debug
output.

Should the return value of test_sort() be stored in a local variable before
being passed to the assertion macro?

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

  reply	other threads:[~2026-05-18  1:20 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 18:30 [PATCH v1 0/2] perf tests: Add tests for uncore and perf metric event sorting Ian Rogers
2026-03-25 18:30 ` [PATCH v1 1/2] perf tests: Add test for uncore " Ian Rogers
2026-03-27 23:36   ` Chen, Zide
2026-03-31  3:06     ` Namhyung Kim
2026-03-25 18:30 ` [PATCH v1 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-03-30 21:53   ` Chen, Zide
2026-03-31  3:08     ` Namhyung Kim
2026-03-31 16:52       ` [PATCH v2 0/2] perf tests: Add tests for uncore and perf metric " Ian Rogers
2026-03-31 16:52         ` [PATCH v2 1/2] perf tests: Add test for uncore " Ian Rogers
2026-03-31 16:52         ` [PATCH v2 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-03-31 18:54         ` [PATCH v3 0/2] Add tests for uncore and perf metric " Ian Rogers
2026-03-31 18:54           ` [PATCH v3 1/2] perf tests: Add test for uncore " Ian Rogers
2026-04-01 21:48             ` Namhyung Kim
2026-03-31 18:54           ` [PATCH v3 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-04-01  3:33             ` Namhyung Kim
2026-05-17 23:28           ` [PATCH v4 0/2] perf tests: Add uncore and x86 topdown event sorting tests Ian Rogers
2026-05-17 23:28             ` [PATCH v4 1/2] perf tests: Add test for uncore event sorting Ian Rogers
2026-05-17 23:49               ` sashiko-bot
2026-05-17 23:28             ` [PATCH v4 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-05-18  0:05               ` sashiko-bot
2026-05-18  0:37             ` [PATCH v5 0/2] perf tests: Add uncore and x86 topdown event sorting tests Ian Rogers
2026-05-18  0:37               ` [PATCH v5 1/2] perf tests: Add test for uncore event sorting Ian Rogers
2026-05-18  1:06                 ` sashiko-bot
2026-05-18  0:37               ` [PATCH v5 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-05-18  1:20                 ` sashiko-bot [this message]
2026-05-18  2:32               ` [PATCH v6 0/2] perf tests: Add uncore and x86 topdown event sorting tests Ian Rogers
2026-05-18  2:32                 ` [PATCH v6 1/2] perf tests: Add test for uncore event sorting Ian Rogers
2026-05-18  2:53                   ` sashiko-bot
2026-05-18  2:32                 ` [PATCH v6 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-05-18  3:08                   ` sashiko-bot
2026-05-18  4:31                 ` [PATCH v7 0/2] perf tests: Add uncore and x86 topdown event sorting tests Ian Rogers
2026-05-18  4:31                   ` [PATCH v7 1/2] perf tests: Add test for uncore event sorting Ian Rogers
2026-05-18  4:48                     ` sashiko-bot
2026-05-18  4:31                   ` [PATCH v7 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-05-18  6:29                   ` [PATCH v8 0/2] perf tests: Add uncore and x86 topdown event sorting tests Ian Rogers
2026-05-18  6:29                     ` [PATCH v8 1/2] perf tests: Add test for uncore event sorting Ian Rogers
2026-05-18  6:29                     ` [PATCH v8 2/2] perf arch x86 tests: Add test for topdown " Ian Rogers
2026-05-20 15:31                     ` [PATCH v8 0/2] perf tests: Add uncore and x86 topdown event sorting tests Ian Rogers
2026-05-20 20:28                       ` Namhyung Kim

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=20260518012040.DDA4DC2BCB0@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