perf tests: Add auto counter reload (ACR) sampling test
PATCH v3 1/1 perf tests: Add auto counter reload (ACR) sampling test
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.
---
V3: Move ratio-to-prev ACR sampling test into ratio_to_prev test.
V2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)
tools/perf/tests/shell/record.sh +91 -1
@@ -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
Signature · 1 line
2.34.1
Kindly ping. :)
Thanks.
Quoted 135 lines · 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_prevtest to verify ACR sampling as well if ACR is supported.Signed-off-by Dapeng Mi <[email protected]>---
V3: Move ratio-to-prev ACR sampling test into
ratio_to_prevtest.
V2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)tools/perf/tests/shell/record.sh +91
-1@@ -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
Ping again ...
Thanks.
Quoted 141 lines · Dapeng
Kindly ping. :)
Thanks.
Quoted 135 lines · 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_prevtest to verify ACR sampling as well if ACR is supported.Signed-off-by Dapeng Mi <[email protected]>---
V3: Move ratio-to-prev ACR sampling test into
ratio_to_prevtest.
V2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)tools/perf/tests/shell/record.sh +91
-1@@ -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
Quoted 58 lines · 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_prevtest to verify ACR sampling as well
if ACR is supported.Signed-off-by Dapeng Mi <[email protected]>---
V3: Move ratio-to-prev ACR sampling test into
ratio_to_prevtest. V2:
https://lore.kernel.org/all/[email protected]/
v1:
https://lore.kernel.org/all/[email protected]/tools/perf/tests/shell/record.sh | 92
+++++++++++++++++++++++++++++++-1 file changed, 91 insertions(+), 1 deletion(-)tools/perf/tests/shell/record.sh +0
-0@@ -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]"
Quoted 8 lines
+ 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
Quoted 101 lines
+ 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]"tools/perf/tests/shell/record.sh +2
-0+} +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/nulltools/perf/tests/shell/record.sh +0
-0@@ -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, soacr_maskmust 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 minimumtools/perf/tests/shell/record.sh +0
-0@@ -457,6 +546,7 @@ test_leader_samplingtest_topdown_leader_sampling
test_precise_max
test_callgraph
+test_acr_sampling
test_ratio_to_prev# restore the default value
Quoted 60 lines · Thomas
Quoted 59 lines · 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_prevtest to verify ACR sampling as well
if ACR is supported.Signed-off-by Dapeng Mi <[email protected]>---
V3: Move ratio-to-prev ACR sampling test into
ratio_to_prevtest. V2:
https://lore.kernel.org/all/[email protected]/
v1:
https://lore.kernel.org/all/[email protected]/tools/perf/tests/shell/record.sh | 92
+++++++++++++++++++++++++++++++-1 file changed, 91 insertions(+), 1 deletion(-)tools/perf/tests/shell/record.sh +0
-0@@ -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
Quoted 8 lines
Quoted 7 lines
+ 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.
Quoted 105 lines
Thanks,
TomQuoted 101 lines
+ 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]"tools/perf/tests/shell/record.sh +2
-0+} +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/nulltools/perf/tests/shell/record.sh +0
-0@@ -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, soacr_maskmust 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 minimumtools/perf/tests/shell/record.sh +0
-0@@ -457,6 +546,7 @@ test_leader_samplingtest_topdown_leader_sampling
test_precise_max
test_callgraph
+test_acr_sampling
test_ratio_to_prev# restore the default value
Ian Rogers
reviewerQuoted 62 lines · 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_prevtest to verify ACR sampling as well if ACR is supported.Signed-off-by Dapeng Mi <[email protected]>---
V3: Move ratio-to-prev ACR sampling test into
ratio_to_prevtest.
V2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)tools/perf/tests/shell/record.sh +36
-0@@ -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]"
tools/perf/tests/shell/record.sh test_callgraph() { · line 450
Quoted 10 lines
tools/perf/tests/shell/record.sh +9
-0+ 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}"
Could there also be cpu_lowpower coverage? What about e-core or p-core only devices?
Thanks,
Ian
Quoted 67 lines
tools/perf/tests/shell/record.sh +46
-2echo "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
Quoted 66 lines · Ian Rogers
Quoted 65 lines · 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_prevtest to verify ACR sampling as well if ACR is supported.Signed-off-by Dapeng Mi <[email protected]>---
V3: Move ratio-to-prev ACR sampling test into
ratio_to_prevtest.
V2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)tools/perf/tests/shell/record.sh +40
-0@@ -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]"
Quoted 8 lines
tools/perf/tests/shell/record.sh test_callgraph() { · line 450
Quoted 6 lines
tools/perf/tests/shell/record.sh +5
-0+} + 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}"Could there also be
cpu_lowpowercoverage? What about e-core or p-core only devices?
I suspect if the lowpower e-core really supporta ACR. There should be only one device ARL-H has the lowpower e-core with different uarch. But anyway, I can add cpu_lowpower for the full coverage.
The e-core or p-core only devices would be covered by the basic "ratio_events". Thanks.
Quoted 71 lines
Thanks,
IanQuoted 67 lines
tools/perf/tests/shell/record.sh +46
-2echo "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