From: Josef Bacik <josef@toxicpanda.com>
To: linux-block@vger.kernel.org, kernel-team@fb.com, osandov@fb.com
Subject: [PATCH 2/2] blktests: block/025: an io.latency test
Date: Wed, 5 Dec 2018 10:34:04 -0500 [thread overview]
Message-ID: <20181205153404.26634-3-josef@toxicpanda.com> (raw)
In-Reply-To: <20181205153404.26634-1-josef@toxicpanda.com>
This is a test to verify io.latency is working properly. It does this
by first running a fio job by itself to figure out how fast it runs.
Then we calculate some thresholds, set up 2 cgroups, a fast and a slow
cgroup, and then run the same job in both groups simultaneously. We
should see the slow group get throttled until the first cgroup is able
to finish, and then the slow cgroup will be allowed to finish.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
tests/block/025 | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/block/025.out | 1 +
2 files changed, 134 insertions(+)
create mode 100644 tests/block/025
create mode 100644 tests/block/025.out
diff --git a/tests/block/025 b/tests/block/025
new file mode 100644
index 000000000000..cdaa35c5e335
--- /dev/null
+++ b/tests/block/025
@@ -0,0 +1,133 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+#
+# Test io.latency to make sure it's protecting the higher priority group
+# properly.
+
+. tests/block/rc
+
+DESCRIPTION="test the io.latency interface to make sure it's working right"
+
+requires() {
+ _have_cgroup2_controller_file io io.latency && _have_fio && \
+ _have_program jq
+}
+
+_fio_results_key() {
+ _job=$1
+ _key=$2
+ _resultfile=$3
+
+ jq '.jobs[] | select(.jobname == "'${_job}'") | .'${_key} ${_resultfile}
+}
+
+test_device() {
+ local fio_config_single fio_config_double fio_results fio_args qd
+
+ fio_config_single=${TMPDIR}/single.fio
+ fio_config_double=${TMPDIR}/double.fio
+ fio_results=${TMPDIR}/025.json
+ fio_args="--output-format=json --output=${fio_results}"
+ qd=$(cat ${TEST_DEV_SYSFS}/queue/nr_requests)
+
+ cat << EOF > "${fio_config_single}"
+ [fast]
+ filename=${TEST_DEV}
+ direct=1
+ allrandrepeat=1
+ readwrite=randrw
+ size=4G
+ ioengine=libaio
+ iodepth=${qd}
+ fallocate=none
+ randseed=12345
+EOF
+
+ cat << EOF > "${fio_config_double}"
+ [global]
+ filename=${TEST_DEV}
+ direct=1
+ allrandrepeat=1
+ readwrite=randrw
+ size=4G
+ ioengine=libaio
+ iodepth=${qd}
+ fallocate=none
+ randseed=12345
+
+ [fast]
+ cgroup=blktests/fast
+
+ [slow]
+ cgroup=blktests/slow
+EOF
+ # We run the test once so we have an idea of how fast this workload will
+ # go with nobody else doing IO on the device.
+ if ! fio ${fio_args} ${fio_config_single}; then
+ echo "fio exited with status $?"
+ return 1
+ fi
+
+ _time_taken=$(_fio_results_key fast job_runtime ${fio_results})
+ if [ "${_time_taken}" = "" ]; then
+ echo "fio doesn't report job_runtime"
+ return 1
+ fi
+
+ echo "normal time taken ${_time_taken}" >> $FULL
+
+ # There's no way to predict how the two workloads are going to affect
+ # each other, so we weant to set thresholds to something reasonable so
+ # we can verify io.latency is doing something. This means we set 15%
+ # for the fast cgroup, just to give us enough wiggle room as throttling
+ # doesn't happen immediately. But if we have a super fast disk we could
+ # run both groups really fast and make it under our fast threshold, so
+ # we need to set a threshold for the slow group at 50%. We assume that
+ # if it was faster than 50% of the fast threshold then we probably
+ # didn't throttle and we can assume io.latency is broken.
+ _fast_thresh=$((${_time_taken} + ${_time_taken} * 15 / 100))
+ _slow_thresh=$((${_time_taken} + ${_time_taken} * 50 / 100))
+ echo "fast threshold time is ${_fast_thresh}" >> $FULL
+ echo "slow threshold time is ${_slow_thresh}" >> $FULL
+
+ # Create the cgroup files
+ _dir=$(_cgroup2_base_dir)/blktests
+ echo "+io" > ${_dir}/cgroup.subtree_control
+ mkdir ${_dir}/fast
+ mkdir ${_dir}/slow
+
+ # We set the target to 1usec because we could have a fast device that is
+ # capable of remarkable IO latencies that would skew the test. It needs
+ # to be low enough that we do actually throttle the slow group,
+ # otherwise the test will fail when there's nothing wrong.
+ _major=$((0x$(stat -c "%t" ${TEST_DEV})))
+ _minor=$((0x$(stat -c "%T" ${TEST_DEV})))
+ echo "${_major}:${_minor} is our device" >> $FULL
+ if ! echo "${_major}:${_minor} target=1" > ${_dir}/fast/io.latency; then
+ echo "Failed to set our latency target"
+ return 1
+ fi
+
+ if ! fio ${fio_args} ${fio_config_double}; then
+ echo "fio exited with status $?"
+ return 1
+ fi
+
+ _fast_time=$(_fio_results_key fast job_runtime ${fio_results})
+ echo "Fast time ${_fast_time}" >> $FULL
+ _slow_time=$(_fio_results_key slow job_runtime ${fio_results})
+ echo "Slow time ${_slow_time}" >> $FULL
+
+ if [ ${_fast_thresh} -lt ${_fast_time} ]; then
+ echo "Too much of a performance drop for the protected workload"
+ return 1
+ fi
+
+ if [ ${_slow_thresh} -gt ${_slow_time} ]; then
+ echo "The slow group does not appear to have been throttled"
+ return 1
+ fi
+
+ echo "Silence is golden"
+ return 0
+}
diff --git a/tests/block/025.out b/tests/block/025.out
new file mode 100644
index 000000000000..c19ff631b9b5
--- /dev/null
+++ b/tests/block/025.out
@@ -0,0 +1 @@
+Silence is golden
--
2.14.3
next prev parent reply other threads:[~2018-12-05 15:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 15:34 [PATCH 0/2][V2] io.latency test for blktests Josef Bacik
2018-12-05 15:34 ` [PATCH 1/2] blktests: add cgroup2 infrastructure Josef Bacik
2018-12-20 23:55 ` Omar Sandoval
2018-12-05 15:34 ` Josef Bacik [this message]
2018-12-06 9:04 ` [PATCH 0/2][V2] io.latency test for blktests Omar Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181205153404.26634-3-josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-block@vger.kernel.org \
--cc=osandov@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).