if [ ! -f /sys/bus/event_source/devices/cpu/caps/branches ] &&
[ ! -f /sys/bus/event_source/devices/cpu_core/caps/branches ] then echo"Skip: only x86 CPUs support LBR"
exit 2 fi
trap_cleanup() { echo"Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
lbr_callgraph_test() {
test="LBR callgraph"
echo"$test" if ! perf record -e cycles --call-graph lbr -o "${perfdata}" perf test -w thloop then echo"$test [Failed support missing]" if [ $err -eq 0 ] then
err=2 fi
return fi
if ! perf report --stitch-lbr -i "${perfdata}" > "${perfdata}".txt then cat"${perfdata}".txt echo"$test [Failed in perf report]"
err=1
return fi
echo"$test [Success]"
}
lbr_test() {
local branch_flags=$1
local test="LBR $2 test"
local threshold=$3
local out
local sam_nr
local bs_nr
local zero_nr
local r
echo"$test" if ! perf record -e cycles $branch_flags -o "${perfdata}" perf test -w thloop then echo"$test [Failed support missing]"
perf record -e cycles $branch_flags -o "${perfdata}" perf test -w thloop || true if [ $err -eq 0 ] then
err=2 fi
return fi
out=$(perf report -D -i "${perfdata}" 2> /dev/null | grep -A1 'PERF_RECORD_SAMPLE')
sam_nr=$(echo"$out" | grep -c 'PERF_RECORD_SAMPLE' || true) if [ $sam_nr -eq 0 ] then echo"$test [Failed no samples captured]"
err=1
return fi echo"$test: $sam_nr samples"
bs_nr=$(echo"$out" | grep -c 'branch stack: nr:' || true) if [ $sam_nr -ne $bs_nr ] then echo"$test [Failed samples missing branch stacks]"
err=1
return fi
zero_nr=$(echo"$out" | grep -A3 'branch stack: nr:0' | grep thread | grep -cv swapper || true)
r=$(($zero_nr * 100 / $bs_nr)) if [ $r -gt $threshold ]; then echo"$test [Failed empty br stack ratio exceed $threshold%: $r%]"
err=1
return fi
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.