Lines Matching +full:cpu +full:- +full:2
3 # SPDX-License-Identifier: GPL-2.0
5 set -e
8 stat_output=$(mktemp /tmp/perf-stat-test-output.XXXXX)
11 rm -f "${stat_output}"
12 trap - EXIT TERM INT
25 if ! perf stat true 2>&1 | grep -E -q "Performance counter stats for 'true':"
36 if ! perf stat --null true 2>&1 | grep -E -q "Performance counter stats for 'true':"
48 if [[ ! -f /sys/devices/system/cpu/cpu$i/online || \
49 $(cat /sys/devices/system/cpu/cpu$i/online) == "0" ]]
55 echo "Failed to find offline CPU"
60 cpu=$(find_offline_cpu)
61 echo "Offline CPU stat command test (cpu $cpu)"
62 if ! perf stat "-C$cpu" -e cycles true 2>&1 | grep -E -q "No supported events found."
64 echo "Offline CPU stat command test [Failed]"
68 echo "Offline CPU stat command test [Success]"
73 if ! perf stat record -e task-clock -o - true | perf stat report -i - 2>&1 | \
74 grep -E -q "Performance counter stats for 'pipe':"
85 if ! perf stat record -e task-clock -o - true | perf script -i - 2>&1 | \
86 grep -E -q "CPU[[:space:]]+THREAD[[:space:]]+VAL[[:space:]]+ENA[[:space:]]+RUN[[:space:]]+TIME[[:space:]]+EVENT"
97 if ! perf stat -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}' \
98 true 2>&1 | grep -q 'seconds time elapsed'
103 if ! perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W' \
104 true > /dev/null 2>&1
115 # parse-events reorders this.
117 if ! perf stat -e '{slots,topdown-retiring}' true > /dev/null 2>&1
125 failure=$2
126 if perf stat -e "$events" true 2>&1 | grep -E -q "<not supported>"
133 do_topdown_group_test "{slots,topdown-retiring}" "events not supported"
136 "context-switches" "faults")
137 for ((i = 0; i < ${#filler_events[@]}; i+=2))
141 do_topdown_group_test "$filler1,topdown-retiring,slots" \
142 "slots not reordered first in no-group case"
143 do_topdown_group_test "slots,$filler1,topdown-retiring" \
144 "topdown metrics event not reordered in no-group case"
145 do_topdown_group_test "{$filler1,topdown-retiring,slots}" \
147 do_topdown_group_test "{$filler1,slots},topdown-retiring" \
149 do_topdown_group_test "topdown-retiring,{$filler1,slots}" \
151 do_topdown_group_test "{$filler1,slots},{topdown-retiring}" \
153 do_topdown_group_test "{topdown-retiring},{$filler1,slots}" \
155 do_topdown_group_test "{$filler1,slots},$filler2,topdown-retiring" \
156 "non-adjacent topdown metrics group not move into slots group"
157 do_topdown_group_test "$filler2,topdown-retiring,{$filler1,slots}" \
158 "non-adjacent topdown metrics group not move into slots group last"
159 do_topdown_group_test "{$filler1,slots},{$filler2,topdown-retiring}" \
161 do_topdown_group_test "{$filler1,topdown-retiring},{$filler2,slots}" \
164 if test "$td_err" -eq 0
177 ok_grouping="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring},branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references"
178 if ! perf stat --no-merge -e "$ok_grouping" true > /dev/null 2>&1
183 group_needs_break="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring,branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references}:W"
184 if perf stat --no-merge -e "$group_needs_break" true 2>&1 | grep -E -q "<not supported>"
194 # Test --cputype argument.
198 if perf stat --cputype="123" -e instructions true > /dev/null 2>&1
208 for i in $devs/cpu $devs/cpu_atom $devs/armv8_pmuv3_0 $devs/armv8_cortex_*
211 if test -d "$i"
216 if perf stat -e "$i_base/instructions/" true > /dev/null 2>&1
229 if ! perf stat --cputype="$pmu" -e instructions true 2>&1 | grep -E -q "instructions"
240 # each CPU type.
244 pmus=$(ls /sys/bus/event_source/devices/*/cpus 2>/dev/null | wc -l)
245 if [ "$pmus" -lt 1 ]
251 cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " | wc -l)
255 # can fall back to task-clock and so the end count may be 0. Fail if neither
257 if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
267 echo "stat -C <cpu> test"
268 # Test the full online CPU list (ranges and lists)
269 online_cpus=$(cat /sys/devices/system/cpu/online)
270 if ! perf stat -C "$online_cpus" -a true > "${stat_output}" 2>&1
272 echo "stat -C <cpu> test [Failed - command failed for cpus $online_cpus]"
278 if ! grep -E -q "Performance counter stats for" "${stat_output}"
280 echo "stat -C <cpu> test [Failed - missing output for cpus $online_cpus]"
286 # Test each individual online CPU
287 for cpu_dir in /sys/devices/system/cpu/cpu[0-9]*; do
288 cpu=${cpu_dir##*/cpu}
290 if [ -f "$cpu_dir/online" ] && [ "$(cat "$cpu_dir/online")" -eq 0 ]
295 if ! perf stat -C "$cpu" -a true > "${stat_output}" 2>&1
297 echo "stat -C <cpu> test [Failed - command failed for cpu $cpu]"
302 if ! grep -E -q "Performance counter stats for" "${stat_output}"
304 echo "stat -C <cpu> test [Failed - missing output for cpu $cpu]"
314 if [ -d "/sys/devices/system/cpu/cpu0" ]
316 if [ ! -f "/sys/devices/system/cpu/cpu0/online" ] || [ "$(cat /sys/devices/system/cpu/cpu0/online)" -eq 1 ]
321 if [ -d "/sys/devices/system/cpu/cpu1" ]
323 if [ ! -f "/sys/devices/system/cpu/cpu1/online" ] || [ "$(cat /sys/devices/system/cpu/cpu1/online)" -eq 1 ]
329 if [ $c0_online -eq 1 ] && [ $c1_online -eq 1 ]
332 if ! perf stat -C "0,1" -a true > "${stat_output}" 2>&1
334 echo "stat -C <cpu> test [Failed - command failed for cpus 0,1]"
339 if ! grep -E -q "Performance counter stats for" "${stat_output}"
341 echo "stat -C <cpu> test [Failed - missing output for cpus 0,1]"
347 # Test range "0-1"
348 if ! perf stat -C "0-1" -a true > "${stat_output}" 2>&1
350 echo "stat -C <cpu> test [Failed - command failed for cpus 0-1]"
355 if ! grep -E -q "Performance counter stats for" "${stat_output}"
357 echo "stat -C <cpu> test [Failed - missing output for cpus 0-1]"
364 echo "stat -C <cpu> test [Success]"
368 echo "stat -A test"
369 if ! perf stat -A -a true > "${stat_output}" 2>&1
371 echo "stat -A test [Failed - command failed]"
377 if ! grep -E -q "CPU" "${stat_output}"
379 echo "stat -A test [Failed - missing CPU column]"
384 echo "stat -A test [Success]"
388 echo "stat -d test"
389 if ! perf stat -d true > "${stat_output}" 2>&1
391 echo "stat -d test [Failed - command failed]"
397 if ! grep -E -q "Performance counter stats" "${stat_output}"
399 echo "stat -d test [Failed - missing output]"
405 if ! perf stat -dd true > "${stat_output}" 2>&1
407 echo "stat -dd test [Failed - command failed]"
413 if ! grep -E -q "Performance counter stats" "${stat_output}"
415 echo "stat -dd test [Failed - missing output]"
421 if ! perf stat -ddd true > "${stat_output}" 2>&1
423 echo "stat -ddd test [Failed - command failed]"
429 if ! grep -E -q "Performance counter stats" "${stat_output}"
431 echo "stat -ddd test [Failed - missing output]"
437 echo "stat -d test [Success]"
441 echo "stat -r test"
442 if ! perf stat -r 2 true > "${stat_output}" 2>&1
444 echo "stat -r test [Failed - command failed]"
450 if ! grep -E -q "\([[:space:]]*\+-.*%[[:space:]]*\)" "${stat_output}"
452 echo "stat -r test [Failed - missing variance]"
457 echo "stat -r test [Success]"
461 echo "stat -p test"
464 if ! perf stat -p $pid > "${stat_output}" 2>&1
466 echo "stat -p test [Failed - command failed]"
469 kill $pid 2>/dev/null || true
470 wait $pid 2>/dev/null || true
474 if ! grep -E -q "Performance counter stats" "${stat_output}"
476 echo "stat -p test [Failed - missing output]"
480 echo "stat -p test [Success]"
482 kill $pid 2>/dev/null || true
483 wait $pid 2>/dev/null || true
487 echo "stat -D test"
488 if ! env LC_ALL=C perf stat -D 1000 -e duration_time sleep 2 > "${stat_output}" 2>&1
490 echo "stat -D test [Failed - command failed]"
496 duration=$(grep "duration_time" "${stat_output}" | awk '{print $1}' | tr -d ',')
499 if [ -z "$duration" ] || [ -z "$elapsed" ]
501 echo "stat -D test [Failed - failed to find duration_time or time elapsed in output]"
508 if ! awk -v d="$duration" -v e="$elapsed" '
510 diff = d - (e * 1e9);
511 if (diff < 0) diff = -diff;
530 echo "stat -D test [Failed - validation failed]"
535 echo "stat -D test [Success]"