From: Josef Bacik <josef@toxicpanda.com>
To: linux-block@vger.kernel.org, kernel-team@fb.com, osandov@fb.com
Subject: [PATCH 1/2] blktests: add cgroup2 infrastructure
Date: Wed, 5 Dec 2018 10:34:03 -0500 [thread overview]
Message-ID: <20181205153404.26634-2-josef@toxicpanda.com> (raw)
In-Reply-To: <20181205153404.26634-1-josef@toxicpanda.com>
In order to test io.latency and other cgroup related things we need some
supporting helpers to setup and tear down cgroup2. This adds support
for checking that we can even configure cgroup2 things, set them up if
need be, and then add the cleanup stuff to the main cleanup function so
everything is always in a clean state.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
check | 2 ++
common/rc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/check b/check
index ebd87c097e25..1c9dbc518fa1 100755
--- a/check
+++ b/check
@@ -294,6 +294,8 @@ _cleanup() {
done
unset RESTORE_CPUS_ONLINE
fi
+
+ _cleanup_cgroup2
}
_call_test() {
diff --git a/common/rc b/common/rc
index 8a892bcd5fde..a785f2329687 100644
--- a/common/rc
+++ b/common/rc
@@ -202,3 +202,51 @@ _test_dev_in_hotplug_slot() {
_filter_xfs_io_error() {
sed -e 's/^\(.*\)64\(: .*$\)/\1\2/'
}
+
+_cgroup2_base_dir()
+{
+ grep cgroup2 /proc/mounts | awk '{ print $2 }'
+}
+
+_cleanup_cgroup2()
+{
+ _dir=$(_cgroup2_base_dir)/blktests
+ [ -d "${_dir}" ] || return
+
+ for i in $(find ${_dir} -type d | tac)
+ do
+ rmdir $i
+ done
+}
+
+_have_cgroup2()
+{
+ if ! grep -q 'cgroup2' /proc/mounts; then
+ SKIP_REASON="This test requires cgroup2"
+ return 1
+ fi
+ return 0
+}
+
+_have_cgroup2_controller_file()
+{
+ _have_cgroup2 || return 1
+
+ _controller=$1
+ _file=$2
+ _dir=$(_cgroup2_base_dir)
+
+ if ! grep -q ${_controller} ${_dir}/cgroup.controllers; then
+ SKIP_REASON="No support for ${_controller} cgroup controller"
+ return 1
+ fi
+
+ mkdir ${_dir}/blktests
+ echo "+${_controller}" > ${_dir}/cgroup.subtree_control
+ if [ ! -f ${_dir}/blktests/${_file} ]; then
+ _cleanup_cgroup2
+ SKIP_REASON="Cgroup file ${_file} doesn't exist"
+ return 1
+ fi
+ return 0
+}
--
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 ` Josef Bacik [this message]
2018-12-20 23:55 ` [PATCH 1/2] blktests: add cgroup2 infrastructure Omar Sandoval
2018-12-05 15:34 ` [PATCH 2/2] blktests: block/025: an io.latency test Josef Bacik
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-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.