linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Thomas Falcon <thomas.falcon@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	 linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	 Andi Kleen <ak@linux.intel.com>
Subject: Re: [RESEND][PATCH v2 2/2] perf record: Add auto counter reload parse and regression tests
Date: Wed, 24 Sep 2025 14:37:30 -0700	[thread overview]
Message-ID: <CAP-5=fU27BLudDDBGTWxG42oiAXEEC0qy63S7zvBUiS07PxazQ@mail.gmail.com> (raw)
In-Reply-To: <20250902164047.64261-3-thomas.falcon@intel.com>

On Tue, Sep 2, 2025 at 9:41 AM Thomas Falcon <thomas.falcon@intel.com> wrote:
>
> Include event parsing and regression tests for auto counter reload
> and ratio-to-prev event term.
>
> Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>

Reviewed-by: Ian Rogers <irogers@google.com>

There will be conflicts with:
https://lore.kernel.org/linux-perf-users/20250923223312.238185-1-irogers@google.com/
as I refactored parts of the parse-events test. I wouldn't be holding
my breath waiting for those patches to land, so I guess I'll deal with
the issues when they pop up.

Thanks,
Ian

> ---
>  tools/perf/tests/parse-events.c  | 54 ++++++++++++++++++++++++++++++++
>  tools/perf/tests/shell/record.sh | 40 +++++++++++++++++++++++
>  2 files changed, 94 insertions(+)
>
> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> index bb8004397650..67550cc60555 100644
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -1736,6 +1736,53 @@ static int test__intel_pt(struct evlist *evlist)
>         return TEST_OK;
>  }
>
> +static bool test__acr_valid(void)
> +{
> +       struct perf_pmu *pmu = NULL;
> +
> +       while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
> +               if (perf_pmu__has_format(pmu, "acr_mask"))
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
> +static int test__ratio_to_prev(struct evlist *evlist)
> +{
> +       struct evsel *evsel;
> +       int ret;
> +
> +       TEST_ASSERT_VAL("wrong number of entries", 2 * perf_pmus__num_core_pmus() == evlist->core.nr_entries);
> +
> +        evlist__for_each_entry(evlist, evsel) {
> +               if (!perf_pmu__has_format(evsel->pmu, "acr_mask"))
> +                       return TEST_OK;
> +
> +               if (evsel == evlist__first(evlist)) {
> +                       TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
> +                       TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
> +                       TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
> +                       TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
> +                       ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
> +               } else {
> +                       TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
> +                       TEST_ASSERT_VAL("wrong leader", !evsel__is_group_leader(evsel));
> +                       TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 0);
> +                       TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
> +                       ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
> +               }
> +               if (ret)
> +                       return ret;
> +               /*
> +                * The period value gets configured within evlist__config,
> +                * while this test executes only parse events method.
> +                */
> +               TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
> +       }
> +       return TEST_OK;
> +}
> +
>  static int test__checkevent_complex_name(struct evlist *evlist)
>  {
>         struct evsel *evsel = evlist__first(evlist);
> @@ -2249,6 +2296,13 @@ static const struct evlist_test test__events[] = {
>                 .check = test__checkevent_tracepoint,
>                 /* 4 */
>         },
> +       {
> +               .name  = "{cycles,instructions/period=200000,ratio-to-prev=2.0/}",
> +               .valid = test__acr_valid,
> +               .check = test__ratio_to_prev,
> +               /* 5 */
> +       },
> +
>  };
>
>  static const struct evlist_test test__events_pmu[] = {
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index b1ad24fb3b33..0f5841c479e7 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -388,6 +388,45 @@ test_callgraph() {
>    echo "Callgraph test [Success]"
>  }
>
> +test_ratio_to_prev() {
> +  echo "ratio-to-prev test"
> +  if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \
> +     true 2> /dev/null
> +  then
> +    echo "ratio-to-prev [Skipped not supported]"
> +    return
> +  fi
> +  if ! perf record -o /dev/null -e "instructions, cycles/period=100000,ratio-to-prev=0.5/" \
> +     true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group'
> +  then
> +    echo "ratio-to-prev test [Failed elements must be in same group]"
> +    err=1
> +    return
> +  fi
> +  if ! perf record -o /dev/null -e "{instructions,dummy,cycles/period=100000,ratio-to-prev=0.5/}" \
> +     true |& grep -q 'must have same PMU'
> +  then
> +    echo "ratio-to-prev test [Failed elements must have same PMU]"
> +    err=1
> +    return
> +  fi
> +  if ! perf record -o /dev/null -e "{instructions,cycles/ratio-to-prev=0.5/}" \
> +     true |& grep -q 'Event period term or count (-c) must be set when using ratio-to-prev term.'
> +  then
> +    echo "ratio-to-prev test [Failed period must be set]"
> +    err=1
> +    return
> +  fi
> +  if ! perf record -o /dev/null -e "{cycles/ratio-to-prev=0.5/}" \
> +     true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group'
> +  then
> +    echo "ratio-to-prev test [Failed need 2+ events]"
> +    err=1
> +    return
> +  fi
> +  echo "Basic ratio-to-prev record test [Success]"
> +}
> +
>  # raise the limit of file descriptors to minimum
>  if [[ $default_fd_limit -lt $min_fd_limit ]]; then
>         ulimit -Sn $min_fd_limit
> @@ -404,6 +443,7 @@ test_leader_sampling
>  test_topdown_leader_sampling
>  test_precise_max
>  test_callgraph
> +test_ratio_to_prev
>
>  # restore the default value
>  ulimit -Sn $default_fd_limit
> --
> 2.50.1
>

  reply	other threads:[~2025-09-24 21:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 16:40 [RESEND][PATCH v2 0/2] perf record: ratio-to-prev event term for auto counter reload Thomas Falcon
2025-09-02 16:40 ` [RESEND][PATCH v2 1/2] perf record: Add ratio-to-prev term Thomas Falcon
2025-09-24 21:34   ` Ian Rogers
2025-09-02 16:40 ` [RESEND][PATCH v2 2/2] perf record: Add auto counter reload parse and regression tests Thomas Falcon
2025-09-24 21:37   ` Ian Rogers [this message]
2025-09-24 19:09 ` [RESEND][PATCH v2 0/2] perf record: ratio-to-prev event term for auto counter reload Falcon, Thomas
2025-09-30  7:28 ` Mi, Dapeng
2025-10-02 15:38   ` Falcon, Thomas
2025-10-09  2:31     ` Mi, Dapeng
2025-10-02 19:35 ` Arnaldo Carvalho de Melo
2025-10-02 21:57   ` Falcon, Thomas

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='CAP-5=fU27BLudDDBGTWxG42oiAXEEC0qy63S7zvBUiS07PxazQ@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --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 \
    /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).