-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rublk: add one script for running fio test for rublk/zoned
Signed-off-by: Ming Lei <[email protected]>
- Loading branch information
Showing
1 changed file
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# One fio script for running write over zoned device, and fio parsing code | ||
# is borrowed from blktests project | ||
|
||
declare -A TEST_RUN | ||
declare -A FIO_TERSE_FIELDS | ||
FIO_TERSE_FIELDS=( | ||
# Read status | ||
["read io"]=6 | ||
["read bandwidth"]=7 | ||
["read iops"]=8 | ||
["read runtime"]=9 | ||
["read slat min"]=10 | ||
["read slat max"]=11 | ||
["read slat mean"]=12 | ||
["read slat stdev"]=13 | ||
["read clat min"]=14 | ||
["read clat max"]=15 | ||
["read clat mean"]=16 | ||
["read clat stdev"]=17 | ||
# read clat percentiles are 18-37 | ||
["read lat min"]=38 | ||
["read lat max"]=39 | ||
["read lat mean"]=40 | ||
["read lat stdev"]=41 | ||
["read bandwidth min"]=42 | ||
["read bandwidth max"]=43 | ||
["read bandwidth %"]=44 | ||
["read bandwidth mean"]=45 | ||
["read bandwidth stdev"]=46 | ||
|
||
# Write status | ||
["write io"]=47 | ||
["write bandwidth"]=48 | ||
["write iops"]=49 | ||
["write runtime"]=50 | ||
["write slat min"]=51 | ||
["write slat max"]=52 | ||
["write slat mean"]=53 | ||
["write slat stdev"]=54 | ||
["write clat min"]=55 | ||
["write clat max"]=56 | ||
["write clat mean"]=57 | ||
["write clat stdev"]=58 | ||
# write clat percentiles are 59-78 | ||
["write lat min"]=79 | ||
["write lat max"]=80 | ||
["write lat mean"]=81 | ||
["write lat stdev"]=82 | ||
["write bandwidth min"]=83 | ||
["write bandwidth max"]=84 | ||
["write bandwidth %"]=85 | ||
["write bandwidth mean"]=86 | ||
["write bandwidth stdev"]=87 | ||
|
||
# Trim status | ||
["trim io"]=88 | ||
["trim bandwidth"]=89 | ||
["trim iops"]=90 | ||
["trim runtime"]=91 | ||
["trim slat min"]=92 | ||
["trim slat max"]=93 | ||
["trim slat mean"]=94 | ||
["trim slat stdev"]=95 | ||
["trim clat min"]=96 | ||
["trim clat max"]=97 | ||
["trim clat mean"]=98 | ||
["trim clat stdev"]=99 | ||
# trim clat percentiles are 100-119 | ||
["trim lat min"]=120 | ||
["trim lat max"]=121 | ||
["trim lat mean"]=122 | ||
["trim lat stdev"]=123 | ||
["trim bandwidth min"]=124 | ||
["trim bandwidth max"]=125 | ||
["trim bandwidth %"]=126 | ||
["trim bandwidth mean"]=127 | ||
["trim bandwidth stdev"]=128 | ||
|
||
# CPU usage | ||
["user cpu"]=129 | ||
["system cpu"]=130 | ||
["context switches"]=131 | ||
["major page faults"]=132 | ||
["minor page faults"]=133 | ||
|
||
# IO depth distribution | ||
["io depth <=1"]=134 | ||
["io depth 2"]=135 | ||
["io depth 4"]=136 | ||
["io depth 8"]=137 | ||
["io depth 16"]=138 | ||
["io depth 32"]=139 | ||
["io depth >=64"]=140 | ||
|
||
# IO latency distribution | ||
["io latency <=2 us"]=141 | ||
["io latency 4 us"]=142 | ||
["io latency 10 us"]=143 | ||
["io latency 20 us"]=144 | ||
["io latency 50 us"]=145 | ||
["io latency 100 us"]=146 | ||
["io latency 250 us"]=147 | ||
["io latency 500 us"]=148 | ||
["io latency 750 us"]=149 | ||
["io latency 1000 us"]=150 | ||
["io latency <=2 ms"]=151 | ||
["io latency 4 ms"]=152 | ||
["io latency 10 ms"]=153 | ||
["io latency 20 ms"]=154 | ||
["io latency 50 ms"]=155 | ||
["io latency 100 ms"]=156 | ||
["io latency 250 ms"]=157 | ||
["io latency 500 ms"]=158 | ||
["io latency 750 ms"]=159 | ||
["io latency 1000 ms"]=160 | ||
["io latency 2000 ms"]=161 | ||
["io latency >=2000 ms"]=162 | ||
|
||
# Disk utilization (11 fields per disk) | ||
) | ||
|
||
FIO_OUTPUT="./.fio_perf" | ||
|
||
_fio_perf_report() { | ||
# If there is more than one group, we don't know what to report. | ||
if [[ $(wc -l < "$FIO_OUTPUT") -gt 1 ]]; then | ||
echo "_fio_perf: too many terse lines" >&2 | ||
return | ||
fi | ||
|
||
local name field value | ||
for name in "${FIO_PERF_FIELDS[@]}"; do | ||
field="${FIO_TERSE_FIELDS["$name"]}" | ||
if [[ -z $field ]]; then | ||
echo "_fio_perf: unknown fio terse field '$name'" >&2 | ||
continue | ||
fi | ||
value="$(cut -d ';' -f "$field" "$FIO_OUTPUT")" | ||
TEST_RUN["$FIO_PERF_PREFIX$name"]="$value" | ||
done | ||
} | ||
|
||
__run_fio_libaio() { | ||
local dev=$1 | ||
local bsize=$2 | ||
local rw=$3 | ||
local nr_jobs=$4 | ||
local qd=$5 | ||
local rtime=$6 | ||
|
||
rm -f $FIO_OUTPUT | ||
|
||
fio --zonemode=zbd \ | ||
--output=$FIO_OUTPUT --output-format=terse --terse-version=4 \ | ||
--name=test --filename=${dev} --rw=${rw} \ | ||
--ioengine=libaio --iodepth=${qd} --direct=1 --bs=${bsize} \ | ||
--numjobs=${nr_jobs} --group_reporting --norandommap \ | ||
--cpus_allowed=0-7 --cpus_allowed_policy=split \ | ||
--runtime=${rtime} --ramp_time=5 --time_based > /dev/null 2>&1 | ||
_fio_perf_report | ||
} | ||
|
||
|
||
__run_fio_perf() { | ||
__run_fio_libaio $@ | ||
_fio_perf_report | ||
} | ||
|
||
show_result() | ||
{ | ||
local ucpu=`echo ${TEST_RUN["user cpu"]} | awk -F "." '{print $1}'` | ||
local scpu=`echo ${TEST_RUN["system cpu"]} | awk -F "." '{print $1}'` | ||
printf "\tBS %4s: IOPS %8u BW %8uKiB/s fio_cpu_util(%2u%% %2u%%)\n" $2 ${TEST_RUN["write iops"]} ${TEST_RUN["write bandwidth"]} $ucpu $scpu | ||
} | ||
|
||
run_test_and_show() | ||
{ | ||
__run_fio_perf $@ | ||
show_result $@ | ||
} | ||
|
||
run_dev_fio_perf() | ||
{ | ||
local dev=$1 | ||
local rw=$2 | ||
local nr_jobs=$3 | ||
local rtime=$4 | ||
local qd=32 | ||
local FIO_PERF_FIELDS=("write iops" "write bandwidth" "user cpu" "system cpu") | ||
|
||
printf "%9s %9s: jobs %3u io_depth %4u time %4usec\n" $rw $dev $nr_jobs $qd $rtime | ||
|
||
run_test_and_show ${dev} 4k ${rw} ${nr_jobs} ${qd} ${rtime} | ||
sleep 4 | ||
run_test_and_show ${dev} 128k ${rw} ${nr_jobs} ${qd} ${rtime} | ||
} | ||
|
||
run_dev_fio_perf $@ |