From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Zide Chen <zide.chen@intel.com>,
Falcon Thomas <thomas.falcon@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>,
Xudong Hao <xudong.hao@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [Patch v2] perf tests: Add auto counter reload (ACR) sampling test
Date: Mon, 20 Apr 2026 10:55:01 +0800 [thread overview]
Message-ID: <20260420025501.2133495-1-dapeng1.mi@linux.intel.com> (raw)
Add auto counter reload sampling test to verify that the intended event
records can be captured and the self-reloaded events won't generate any
records.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
V2: 1) add ratio_to_prev option test. 2) Adjust sampling period to
better match the "perf test -w thloop" workload
v1: https://lore.kernel.org/all/20260413010920.546501-1-dapeng1.mi@linux.intel.com/
tools/perf/tests/shell/record.sh | 89 ++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 7cb81cf3444a..a05b0c8b6d6b 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -402,6 +402,94 @@ test_callgraph() {
echo "Callgraph test [Success]"
}
+test_acr_sampling() {
+ events="{instructions/period=40000,acr_mask=0x2/u,cycles/period=20000,acr_mask=0x3/u}"
+ pebs_events="{instructions/period=40000,acr_mask=0x2/pu,cycles/period=20000,acr_mask=0x3/u}"
+ ratio_events="{instructions:u,cycles/period=20000,ratio-to-prev=0.5/u}"
+ p_core_ratio_events="{cpu_core/instructions/u,cpu_core/cycles,period=20000,ratio-to-prev=0.5/u}"
+ e_core_ratio_events="{cpu_atom/instructions/u,cpu_atom/cycles,period=20000,ratio-to-prev=0.5/u}"
+ echo "Auto counter reload (ACR) sampling test"
+ if ! perf record -o "${perfdata}" -e "${events}" ${testprog} 2> /dev/null
+ then
+ echo "Auto counter reload sampling [Skipped not supported]"
+ return
+ fi
+ if ! perf script -i "${perfdata}" -F event | grep -q "instructions"
+ then
+ echo "Auto counter reload sampling [Failed missing instructions event]"
+ err=1
+ return
+ fi
+ if perf script -i "${perfdata}" -F event | grep -q "cycles"
+ then
+ echo "Auto counter reload sampling [Failed cycles event shouldn't be sampled]"
+ err=1
+ return
+ fi
+ if ! perf record -o "${perfdata}" -e "${pebs_events}" ${testprog} 2> /dev/null
+ then
+ echo "Auto counter reload PEBS sampling [Skipped not supported]"
+ return
+ fi
+ if ! perf script -i "${perfdata}" -F event | grep -q "instructions"
+ then
+ echo "Auto counter reload PEBS sampling [Failed missing instructions event]"
+ err=1
+ return
+ fi
+ if perf script -i "${perfdata}" -F event | grep -q "cycles"
+ then
+ echo "Auto counter reload PEBS sampling [Failed cycles event shouldn't be sampled]"
+ err=1
+ return
+ fi
+
+ ratio_err=0
+ do_ratio_to_prev_test() {
+ local events=$1
+ local cpu=$2
+ if ! perf record -o "${perfdata}" -e "${events}" ${testprog} 2> /dev/null
+ then
+ echo "Auto counter reload ${cpu} ratio-to-prev sampling [Failed not supported]"
+ ratio_err=1
+ return
+ fi
+ if ! perf script -i "${perfdata}" -F event | grep -q "instructions"
+ then
+ echo "Auto counter reload ${cpu} ratio-to-prev sampling [Failed missing instructions event]"
+ ratio_err=1
+ return
+ fi
+ if perf script -i "${perfdata}" -F event | grep -q "cycles"
+ then
+ echo "Auto counter reload ${cpu} ratio-to-prev sampling [Failed cycles event shouldn't be sampled]"
+ ratio_err=1
+ return
+ fi
+ }
+
+ # ratio-to-prev sampling would fallback to normal sampling if ACR sampling
+ # is not supported, so acr_mask must be checked before testing ratio-to-prev sampling.
+ if [ -e /sys/bus/event_source/devices/cpu/format/acr_mask ]
+ then
+ do_ratio_to_prev_test "${ratio_events}" ""
+ fi
+ if [ -e /sys/bus/event_source/devices/cpu_core/format/acr_mask ]
+ then
+ do_ratio_to_prev_test "${p_core_ratio_events}" "P-core"
+ fi
+ if [ -e /sys/bus/event_source/devices/cpu_atom/format/acr_mask ]
+ then
+ do_ratio_to_prev_test "${e_core_ratio_events}" "E-core"
+ fi
+ if test "$ratio_err" -eq 0
+ then
+ echo "Auto counter reload sampling [Success]"
+ else
+ err="${ratio_err}"
+ fi
+}
+
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/}" \
@@ -458,6 +546,7 @@ test_topdown_leader_sampling
test_precise_max
test_callgraph
test_ratio_to_prev
+test_acr_sampling
# restore the default value
ulimit -Sn $default_fd_limit
--
2.34.1
next reply other threads:[~2026-04-20 2:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 2:55 Dapeng Mi [this message]
2026-04-20 3:10 ` [Patch v2] perf tests: Add auto counter reload (ACR) sampling test sashiko-bot
2026-04-20 6:35 ` Mi, Dapeng
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=20260420025501.2133495-1-dapeng1.mi@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=xudong.hao@intel.com \
--cc=zide.chen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.