linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Thomas Falcon <thomas.falcon@intel.com>,
	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>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [RESEND][PATCH v2 0/2] perf record: ratio-to-prev event term for auto counter reload
Date: Tue, 30 Sep 2025 15:28:50 +0800	[thread overview]
Message-ID: <ed463cd8-495e-4769-b392-372413ca7db6@linux.intel.com> (raw)
In-Reply-To: <20250902164047.64261-1-thomas.falcon@intel.com>


On 9/3/2025 12:40 AM, Thomas Falcon wrote:
> The Auto Counter Reload (ACR)[1] feature is used to track the
> relative rates of two or more perf events, only sampling
> when a given threshold is exceeded. This helps reduce overhead
> and unnecessary samples. However, enabling this feature
> currently requires setting two parameters:
>
>  -- Event sampling period ("period")
>  -- acr_mask, which determines which events get reloaded
>     when the sample period is reached.
>
> For example, in the following command:
>
> perf record -e "{cpu_atom/branch-misses,period=200000,\
> acr_mask=0x2/ppu,cpu_atom/branch-instructions,period=1000000,\
> acr_mask=0x3/u}" -- ./mispredict
>
> The goal is to limit event sampling to cases when the
> branch miss rate exceeds 20%. If the branch instructions
> sample period is exceeded first, both events are reloaded.
> If branch misses exceed their threshold first, only the
> second counter is reloaded, and a sample is taken.
>
> To simplify this, provide a new “ratio-to-prev” event term
> that works alongside the period event option or -c option.
> This would allow users to specify the desired relative rate
> between events as a ratio, making configuration more intuitive.
>
> With this enhancement, the equivalent command would be:
>
> perf record -e "{cpu_atom/branch-misses/ppu,\
> cpu_atom/branch-instructions,period=1000000,ratio_to_prev=5/u}" \
> -- ./mispredict

Hi Tom,

Does this "ratio-to-prev" option support 3 and more events in ACR group?

If not, should we consider to support the cases there are 3 and more events
in the ACR group? (If I remember correct, the PMU driver should support it).

e.g.,

perf record -e
"{cpu_atom/branch-misses,period=200000,acr_mask=0x6/p,cpu_atom/branches,period=1000000,acr_mask=0x7/,cpu_atom/branches,period=1000000,acr_mask=0x7/}"
-- sleep 1

Of course, this is just an example that indicates the cases are supported,
it doesn't mean the command is meaningful. But we can't exclude that users
have such real requirements.

If we want to support 3 and more events in ACR group (if not already), we'd
better rename the "ratio-to-prev" option to "ratio-to-head" and only allow
the group leader can be set the sampling period explicitly with "period"
option and the sampling period of all other group members can only be
calculated base on the sampling period of group leader and
the "ratio-to-head", maybe like this.

perf record -e
"{cpu_atom/branch-misses,period=200000/p,cpu_atom/branches,ratio-to-head=5/,cpu_atom/branches,ratio-to-head=5/}"
-- sleep 1

Thanks.


>
> or
>
> perf record -e "{cpu_atom/branch-misses/ppu,\
> cpu_atom/branch-instructions,ratio-to-prev=5/u}" -c 1000000 \
> -- ./mispredict
>
> [1] https://lore.kernel.org/lkml/20250327195217.2683619-1-kan.liang@linux.intel.com/
>
> Changes in v2 (mostly suggested by Ian Rogers):
>
> -- Add documentation explaining acr_mask bitmask used by ACR
> -- Move ACR specific implementation to arch/x86/
> -- Provide test cases for event parsing and perf record tests
>
> Thomas Falcon (2):
>   perf record: Add ratio-to-prev term
>   perf record: add auto counter reload parse and regression tests
>
>  tools/perf/Documentation/intel-acr.txt | 53 ++++++++++++++++++
>  tools/perf/Documentation/perf-list.txt |  2 +
>  tools/perf/arch/x86/util/evsel.c       | 53 ++++++++++++++++++
>  tools/perf/tests/parse-events.c        | 54 ++++++++++++++++++
>  tools/perf/tests/shell/record.sh       | 40 ++++++++++++++
>  tools/perf/util/evsel.c                | 76 ++++++++++++++++++++++++++
>  tools/perf/util/evsel.h                |  1 +
>  tools/perf/util/evsel_config.h         |  1 +
>  tools/perf/util/parse-events.c         | 22 ++++++++
>  tools/perf/util/parse-events.h         |  3 +-
>  tools/perf/util/parse-events.l         |  1 +
>  tools/perf/util/pmu.c                  |  3 +-
>  12 files changed, 307 insertions(+), 2 deletions(-)
>  create mode 100644 tools/perf/Documentation/intel-acr.txt
>

  parent reply	other threads:[~2025-09-30  7:29 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
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 [this message]
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=ed463cd8-495e-4769-b392-372413ca7db6@linux.intel.com \
    --to=dapeng1.mi@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.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).