test/nvme_perf: add option to set cpu frequency

If intel_pstate is disabled in boot options, allow to
change CPU frequency using "userspace" cpu governor.

Change-Id: I390492c7be28df408f3cbb774ba5360859649fe0
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3376
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Karol Latecki 2020-07-16 13:37:48 +02:00 committed by Tomasz Zawadzki
parent 88b991768d
commit 0e897f08a6

View File

@ -38,6 +38,7 @@ DISKNO="ALL"
CPUS_ALLOWED=1 CPUS_ALLOWED=1
NOIOSCALING=false NOIOSCALING=false
PRECONDITIONING=true PRECONDITIONING=true
CPUFREQ=""
PERFTOP=false PERFTOP=false
DATE="$(date +'%m_%d_%Y_%H%M%S')" DATE="$(date +'%m_%d_%Y_%H%M%S')"
@ -89,6 +90,9 @@ function usage() {
echo " Can also point to a file containing list of CPUs. [default=$CPUS_ALLOWED]" echo " Can also point to a file containing list of CPUs. [default=$CPUS_ALLOWED]"
echo " --no-preconditioning Skip preconditioning" echo " --no-preconditioning Skip preconditioning"
echo " --no-io-scaling Do not scale iodepth for each device in SPDK fio plugin. [default=$NOIOSCALING]" echo " --no-io-scaling Do not scale iodepth for each device in SPDK fio plugin. [default=$NOIOSCALING]"
echo " --cpu-frequency=INT Run tests with CPUs set to a desired frequency. 'intel_pstate=disable' must be set in"
echo " GRUB options. You can use 'cpupower frequency-info' and 'cpupower frequency-set' to"
echo " check list of available frequencies. Example: --cpu-frequency=1100000."
echo echo
echo "Other options:" echo "Other options:"
echo " --perftop Run perftop measurements on the same CPU cores as specified in --cpu-allowed option." echo " --perftop Run perftop measurements on the same CPU cores as specified in --cpu-allowed option."
@ -132,6 +136,7 @@ while getopts 'h-:' optchar; do
;; ;;
no-preconditioning) PRECONDITIONING=false ;; no-preconditioning) PRECONDITIONING=false ;;
no-io-scaling) NOIOSCALING=true ;; no-io-scaling) NOIOSCALING=true ;;
cpu-frequency=*) CPUFREQ="${OPTARG#*=}" ;;
perftop) PERFTOP=true ;; perftop) PERFTOP=true ;;
*) *)
usage $0 echo "Invalid argument '$OPTARG'" usage $0 echo "Invalid argument '$OPTARG'"
@ -215,6 +220,17 @@ if [[ "$PLUGIN" =~ "kernel" ]]; then
fi fi
fi fi
if [[ -n "$CPUFREQ" ]]; then
if [[ ! "$(cat /proc/cmdline)" =~ "intel_pstate=disable" ]]; then
echo "ERROR: Cannot set custom CPU frequency for test. intel_pstate=disable not in boot options."
false
else
cpu_governor="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"
cpupower frequency-set -g userspace
cpupower frequency-set -f $CPUFREQ
fi
fi
if $PERFTOP; then if $PERFTOP; then
echo "INFO: starting perf record on cores $CPUS_ALLOWED" echo "INFO: starting perf record on cores $CPUS_ALLOWED"
perf record -C $CPUS_ALLOWED -o "$testdir/perf.data" & perf record -C $CPUS_ALLOWED -o "$testdir/perf.data" &
@ -311,6 +327,10 @@ fi
printf "%s,%s,%s,%s,%s,%s,%s,%s,%s\n" ${DISKNO} ${iops_disks} ${mean_lat_disks_usec} ${p99_lat_disks_usec} \ printf "%s,%s,%s,%s,%s,%s,%s,%s,%s\n" ${DISKNO} ${iops_disks} ${mean_lat_disks_usec} ${p99_lat_disks_usec} \
${p99_99_lat_disks_usec} ${stdev_disks_usec} ${mean_slat_disks_usec} ${mean_clat_disks_usec} ${bw} >> $result_file ${p99_99_lat_disks_usec} ${stdev_disks_usec} ${mean_slat_disks_usec} ${mean_clat_disks_usec} ${bw} >> $result_file
if [[ -n "$CPUFREQ" ]]; then
cpupower frequency-set -g $cpu_governor
fi
if [ $PLUGIN = "kernel-io-uring" ]; then if [ $PLUGIN = "kernel-io-uring" ]; then
# Reload the nvme driver so that other test runs are not affected # Reload the nvme driver so that other test runs are not affected
modprobe -rv nvme modprobe -rv nvme