* [Patch v3] perf tests: Add auto counter reload (ACR) sampling test
@ 2026-04-21 4:55 Dapeng Mi
2026-05-21 0:52 ` Mi, Dapeng
2026-05-21 18:01 ` Falcon, Thomas
0 siblings, 2 replies; 4+ messages in thread
From: Dapeng Mi @ 2026-04-21 4:55 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Ian Rogers, Adrian Hunter, Alexander Shishkin
Cc: linux-perf-users, linux-kernel, Zide Chen, Falcon Thomas,
Dapeng Mi, Xudong Hao, Dapeng Mi
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.
Additionally, enhance ratio_to_prev test to verify ACR sampling as well
if ACR is supported.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
V3: Move ratio-to-prev ACR sampling test into ratio_to_prev test.
V2: https://lore.kernel.org/all/20260420025501.2133495-1-dapeng1.mi@linux.intel.com/
v1: https://lore.kernel.org/all/20260413010920.546501-1-dapeng1.mi@linux.intel.com/
tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++-
1 file changed, 91 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 7cb81cf3444a..091d8b0a998b 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -402,7 +402,52 @@ 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}"
+ 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]"
+ echo "Auto counter reload sampling [Success]"
+ 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
+ echo "Auto counter reload sampling [Success]"
+}
+
test_ratio_to_prev() {
+ 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 "ratio-to-prev test"
if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \
true 2> /dev/null
@@ -438,7 +483,51 @@ test_ratio_to_prev() {
err=1
return
fi
- echo "Basic ratio-to-prev record test [Success]"
+
+ 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 sampling]"
+ 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 "Basic ratio-to-prev record test [Success]"
+ else
+ err="${ratio_err}"
+ fi
}
# raise the limit of file descriptors to minimum
@@ -457,6 +546,7 @@ test_leader_sampling
test_topdown_leader_sampling
test_precise_max
test_callgraph
+test_acr_sampling
test_ratio_to_prev
# restore the default value
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch v3] perf tests: Add auto counter reload (ACR) sampling test
2026-04-21 4:55 [Patch v3] perf tests: Add auto counter reload (ACR) sampling test Dapeng Mi
@ 2026-05-21 0:52 ` Mi, Dapeng
2026-05-21 18:01 ` Falcon, Thomas
1 sibling, 0 replies; 4+ messages in thread
From: Mi, Dapeng @ 2026-05-21 0:52 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Ian Rogers, Adrian Hunter, Alexander Shishkin
Cc: linux-perf-users, linux-kernel, Zide Chen, Falcon Thomas,
Dapeng Mi, Xudong Hao
Kindly ping. :)
Thanks.
On 4/21/2026 12:55 PM, Dapeng Mi wrote:
> 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.
>
> Additionally, enhance ratio_to_prev test to verify ACR sampling as well
> if ACR is supported.
>
> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> ---
>
> V3: Move ratio-to-prev ACR sampling test into ratio_to_prev test.
> V2: https://lore.kernel.org/all/20260420025501.2133495-1-dapeng1.mi@linux.intel.com/
> v1: https://lore.kernel.org/all/20260413010920.546501-1-dapeng1.mi@linux.intel.com/
>
> tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++-
> 1 file changed, 91 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 7cb81cf3444a..091d8b0a998b 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -402,7 +402,52 @@ 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}"
> + 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]"
> + echo "Auto counter reload sampling [Success]"
> + 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
> + echo "Auto counter reload sampling [Success]"
> +}
> +
> test_ratio_to_prev() {
> + 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 "ratio-to-prev test"
> if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \
> true 2> /dev/null
> @@ -438,7 +483,51 @@ test_ratio_to_prev() {
> err=1
> return
> fi
> - echo "Basic ratio-to-prev record test [Success]"
> +
> + 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 sampling]"
> + 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 "Basic ratio-to-prev record test [Success]"
> + else
> + err="${ratio_err}"
> + fi
> }
>
> # raise the limit of file descriptors to minimum
> @@ -457,6 +546,7 @@ test_leader_sampling
> test_topdown_leader_sampling
> test_precise_max
> test_callgraph
> +test_acr_sampling
> test_ratio_to_prev
>
> # restore the default value
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch v3] perf tests: Add auto counter reload (ACR) sampling test
2026-04-21 4:55 [Patch v3] perf tests: Add auto counter reload (ACR) sampling test Dapeng Mi
2026-05-21 0:52 ` Mi, Dapeng
@ 2026-05-21 18:01 ` Falcon, Thomas
2026-05-22 1:10 ` Mi, Dapeng
1 sibling, 1 reply; 4+ messages in thread
From: Falcon, Thomas @ 2026-05-21 18:01 UTC (permalink / raw)
To: alexander.shishkin@linux.intel.com, peterz@infradead.org,
acme@kernel.org, dapeng1.mi@linux.intel.com, mingo@redhat.com,
Hunter, Adrian, namhyung@kernel.org, Rogers, Ian
Cc: Chen, Zide, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, Mi, Dapeng1, Hao, Xudong
On Tue, 2026-04-21 at 12:55 +0800, Dapeng Mi wrote:
> 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.
>
> Additionally, enhance ratio_to_prev test to verify ACR sampling as
> well
> if ACR is supported.
>
> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> ---
>
> V3: Move ratio-to-prev ACR sampling test into ratio_to_prev test.
> V2:
> https://lore.kernel.org/all/20260420025501.2133495-1-dapeng1.mi@linux.intel.com/
> v1:
> https://lore.kernel.org/all/20260413010920.546501-1-dapeng1.mi@linux.intel.com/
>
> tools/perf/tests/shell/record.sh | 92
> +++++++++++++++++++++++++++++++-
> 1 file changed, 91 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/record.sh
> b/tools/perf/tests/shell/record.sh
> index 7cb81cf3444a..091d8b0a998b 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -402,7 +402,52 @@ 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}"
> + 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]"
> + echo "Auto counter reload sampling [Success]"
Should this "Success" message be here?
Thanks,
Tom
> + 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
> + echo "Auto counter reload sampling [Success]"
> +}
> +
> test_ratio_to_prev() {
> + 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 "ratio-to-prev test"
> if ! perf record -o /dev/null -e "{instructions,
> cycles/period=100000,ratio-to-prev=0.5/}" \
> true 2> /dev/null
> @@ -438,7 +483,51 @@ test_ratio_to_prev() {
> err=1
> return
> fi
> - echo "Basic ratio-to-prev record test [Success]"
> +
> + 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 sampling]"
> + 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 "Basic ratio-to-prev record test [Success]"
> + else
> + err="${ratio_err}"
> + fi
> }
>
> # raise the limit of file descriptors to minimum
> @@ -457,6 +546,7 @@ test_leader_sampling
> test_topdown_leader_sampling
> test_precise_max
> test_callgraph
> +test_acr_sampling
> test_ratio_to_prev
>
> # restore the default value
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch v3] perf tests: Add auto counter reload (ACR) sampling test
2026-05-21 18:01 ` Falcon, Thomas
@ 2026-05-22 1:10 ` Mi, Dapeng
0 siblings, 0 replies; 4+ messages in thread
From: Mi, Dapeng @ 2026-05-22 1:10 UTC (permalink / raw)
To: Falcon, Thomas, alexander.shishkin@linux.intel.com,
peterz@infradead.org, acme@kernel.org, mingo@redhat.com,
Hunter, Adrian, namhyung@kernel.org, Rogers, Ian
Cc: Chen, Zide, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, Mi, Dapeng1, Hao, Xudong
On 5/22/2026 2:01 AM, Falcon, Thomas wrote:
> On Tue, 2026-04-21 at 12:55 +0800, Dapeng Mi wrote:
>> 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.
>>
>> Additionally, enhance ratio_to_prev test to verify ACR sampling as
>> well
>> if ACR is supported.
>>
>> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
>> ---
>>
>> V3: Move ratio-to-prev ACR sampling test into ratio_to_prev test.
>> V2:
>> https://lore.kernel.org/all/20260420025501.2133495-1-dapeng1.mi@linux.intel.com/
>> v1:
>> https://lore.kernel.org/all/20260413010920.546501-1-dapeng1.mi@linux.intel.com/
>>
>> tools/perf/tests/shell/record.sh | 92
>> +++++++++++++++++++++++++++++++-
>> 1 file changed, 91 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/tests/shell/record.sh
>> b/tools/perf/tests/shell/record.sh
>> index 7cb81cf3444a..091d8b0a998b 100755
>> --- a/tools/perf/tests/shell/record.sh
>> +++ b/tools/perf/tests/shell/record.sh
>> @@ -402,7 +402,52 @@ 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}"
>> + 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]"
>> + echo "Auto counter reload sampling [Success]"
> Should this "Success" message be here?
Yes, If we didn't add the "Success" message here, then no "Success" message
is printed if PEBS is not supported. Thanks.
>
> Thanks,
> Tom
>
>> + 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
>> + echo "Auto counter reload sampling [Success]"
>> +}
>> +
>> test_ratio_to_prev() {
>> + 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 "ratio-to-prev test"
>> if ! perf record -o /dev/null -e "{instructions,
>> cycles/period=100000,ratio-to-prev=0.5/}" \
>> true 2> /dev/null
>> @@ -438,7 +483,51 @@ test_ratio_to_prev() {
>> err=1
>> return
>> fi
>> - echo "Basic ratio-to-prev record test [Success]"
>> +
>> + 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 sampling]"
>> + 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 "Basic ratio-to-prev record test [Success]"
>> + else
>> + err="${ratio_err}"
>> + fi
>> }
>>
>> # raise the limit of file descriptors to minimum
>> @@ -457,6 +546,7 @@ test_leader_sampling
>> test_topdown_leader_sampling
>> test_precise_max
>> test_callgraph
>> +test_acr_sampling
>> test_ratio_to_prev
>>
>> # restore the default value
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-22 1:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-21 4:55 [Patch v3] perf tests: Add auto counter reload (ACR) sampling test Dapeng Mi
2026-05-21 0:52 ` Mi, Dapeng
2026-05-21 18:01 ` Falcon, Thomas
2026-05-22 1:10 ` Mi, Dapeng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox