[RFC RESEND V3 blktests] block/032: add test case for open and close rqos policy w/ io

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test case is to test switching rqos policy w/ io running.
The fio is running under cgroup with blkio controller opened.

Signed-off-by: Wang Jianchao (Kuaishou) <jianchao.wan9@xxxxxxxxx>
---
 tests/block/032     | 86 +++++++++++++++++++++++++++++++++++++++++++++
 tests/block/032.out |  2 ++
 2 files changed, 88 insertions(+)
 create mode 100755 tests/block/032
 create mode 100644 tests/block/032.out

diff --git a/tests/block/032 b/tests/block/032
new file mode 100755
index 0000000..c256ff2
--- /dev/null
+++ b/tests/block/032
@@ -0,0 +1,86 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Wang Jianchao
+#
+# Stress test to run the fio in cgroup and iocost/iolatency/ioprio switching
+# concurrently. It mainly to verify the lifecycle of rqos when rqos policy
+# is deactivated.
+
+. tests/block/rc
+. common/cgroup
+
+DESCRIPTION="Stress test for concurrent fio in cgroup and rqos policy switching"
+TIMED=1
+
+requires() {
+	_have_cgroup2_controller io && _have_fio
+}
+
+test_device() {
+
+	echo "Running ${TEST_NAME}"
+
+	_init_cgroup2
+
+	# setup cgroups
+	local cgrp2_dir=$(_cgroup2_base_dir)
+	echo "+io" > ${cgrp2_dir}/cgroup.subtree_control
+	echo "+io" > "${CGROUP2_DIR}/cgroup.subtree_control"
+
+	if _test_dev_is_rotational; then
+		size="32m"
+	else
+		size="1g"
+	fi
+
+	local rqos=("wbt" "iolat" "iocost" "ioprio")
+	local devn=`cat ${TEST_DEV_SYSFS}/dev`
+	local cgrp
+
+	fio_jobs=()
+	for ((cgrp=0; cgrp<8; cgrp++))
+	do
+		mkdir -p "$CGROUP2_DIR/block032-$cgrp"
+		fio_jobs+=("--name=job$cgrp" "--cgroup="blktests/block032-$cgrp"")
+	done
+
+	# start fio job
+	fio --rw=randread --direct=1 --ioengine=libaio --iodepth=128 \
+	    --bs=4K --group_reporting=1 --loops=100000 --runtime=120 \
+	    --filename=${TEST_DEV} --size=${size} \
+	    "${fio_jobs[@]}" > /dev/null &
+
+	start_time=$(date +%s)
+	timeout=${TIMEOUT:=900}
+	while kill -0 $! 2>/dev/null; do
+		idx=$((RANDOM % ${#rqos[@]}))
+		pol=${rqos[$idx]}
+		cat ${TEST_DEV_SYSFS}/queue/qos | grep "\[$pol\]" > /dev/null
+		if [ $? -eq 0 ];then
+			echo "-$pol" > ${TEST_DEV_SYSFS}/queue/qos
+		else
+			echo "+$pol" > ${TEST_DEV_SYSFS}/queue/qos
+			case $pol in
+				"iocost")
+					echo "$devn enable=1 ctrl=auto" > ${cgrp2_dir}/io.cost.qos
+					echo "$devn ctrl=auto" > ${cgrp2_dir}/io.cost.model
+					;;
+				"iolat")
+					;;
+				"ioprio")
+					;;
+				*)
+					;;
+			esac
+		fi
+		sleep .2
+		end_time=$(date +%s)
+		if (( end_time - start_time > timeout + 15 )); then
+			echo "fio did not finish after $timeout seconds!"
+			break
+		fi
+	done
+
+	_exit_cgroup2
+	echo "Test complete"
+}
diff --git a/tests/block/032.out b/tests/block/032.out
new file mode 100644
index 0000000..3604e9e
--- /dev/null
+++ b/tests/block/032.out
@@ -0,0 +1,2 @@
+Running block/032
+Test complete
-- 
2.17.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux