backup_governor()
{
policies=$(ls $CPUFREQROOT| grep "policy[0-9].*") for policy in $policies; do
cur_gov=$(find_current_governor $policy) echo"$policy $cur_gov" >> $OUTFILE.backup_governor.log done
printf "Governor $cur_gov backup done.\n"
}
restore_governor()
{
i=0;
policies=$(awk '{print $1}' $OUTFILE.backup_governor.log) for policy in $policies; do
let i++;
governor=$(sed -n ''$i'p' $OUTFILE.backup_governor.log | awk '{print $2}')
# $1: governor
switch_governor()
{
policies=$(ls $CPUFREQROOT| grep "policy[0-9].*") for policy in $policies; do
filepath=$CPUFREQROOT/$policy/scaling_available_governors
# Exit if cpu isn't managed by cpufreq core if [ ! -f $filepath ]; then
return; fi
count=$(count_cpus) if [ $count = 0 ]; then
printf "No cpu is managed by cpufreq core, exiting\n"
exit; else
printf "AMD P-state manages: $count CPUs\n" fi
# unit test for amd-pstate kernel driver
amd_pstate_basic
m) # --comparative-test
COMPARATIVE_TEST=$OPTARG
;;
*)
help
;;
esac done
}
command_perf()
{ if ! $PERF -v; then echo $msg please install perf or provide perf binary path as argument >&2
exit $ksft_skip fi
}
command_tbench()
{ if ! command -v tbench > /dev/null; then if apt policy dbench > /dev/null 2>&1; then echo $msg apt install dbench >&2
exit $ksft_skip elif yum list available | grep dbench > /dev/null 2>&1; then echo $msg yum install dbench >&2
exit $ksft_skip fi fi
if ! command -v tbench > /dev/null; then echo $msg please install tbench. >&2
exit $ksft_skip fi
}
prerequisite()
{ if ! echo"$ARCH" | grep -q x86; then echo"$0 # Skipped: Test can only run on x86 architectures."
exit $ksft_skip fi
if ! echo"$VENDOR" | grep -iq amd; then echo"$0 # Skipped: Test can only run on AMD CPU." echo"$0 # Current cpu vendor is $VENDOR."
exit $ksft_skip fi
scaling_driver=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver) if [ "$COMPARATIVE_TEST" = "" ]; then if [ "$scaling_driver" != "$CURRENT_TEST" ]; then echo"$0 # Skipped: Test can only run on $CURRENT_TEST driver or run comparative test." echo"$0 # Please set X86_AMD_PSTATE enabled or run comparative test." echo"$0 # Current cpufreq scaling driver is $scaling_driver."
exit $ksft_skip fi else
case "$FUNC" in "tbench" | "gitsource") if [ "$scaling_driver" != "$COMPARATIVE_TEST" ]; then echo"$0 # Skipped: Comparison test can only run on $COMPARISON_TEST driver." echo"$0 # Current cpufreq scaling driver is $scaling_driver."
exit $ksft_skip fi
;;
*) echo"$0 # Skipped: Comparison test are only for tbench or gitsource." echo"$0 # Current comparative test is for $FUNC."
exit $ksft_skip
;;
esac fi
if [ ! -w /dev ]; then echo $msg please run this as root >&2
exit $ksft_skip fi
case "$FUNC" in "all")
command_perf
command_tbench
;;
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.