Re: [PATCH blktests] throtl: set "io" to subtree_control only if required

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

 



在 2024/11/15 20:12, Shin'ichiro Kawasaki 写道:
It was reported the thortl test cases fail on the systems, which already
sets "io" in cgourp2 subtree_control files. The fail happens when
writing "-io" to the subtree_control files at clean up.

To avoid the failure, check if the system already sets "io". If so, skip
writing "+io" at set up, and writing "-io" at clean up.

Reported-by: Yi Zhang <yi.zhang@xxxxxxxxxx>
Link: https://github.com/osandov/blktests/issues/149
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
---
  tests/throtl/rc | 22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)


LGTM, thanks for the patch
Reviewed-by: Yu Kuai <yukuai3@xxxxxxxxxx>

diff --git a/tests/throtl/rc b/tests/throtl/rc
index 2e26fd2..9c264bd 100644
--- a/tests/throtl/rc
+++ b/tests/throtl/rc
@@ -10,6 +10,8 @@
THROTL_DIR=$(echo "$TEST_NAME" | tr '/' '_')
  THROTL_DEV=dev_nullb
+declare THROTL_CLEAR_BASE_SUBTREE_CONTROL_IO
+declare THROTL_CLEAR_CGROUP2_DIR_CONTROL_IO
group_requires() {
  	_have_root
@@ -31,8 +33,16 @@ _set_up_throtl() {
  		return 1
  	fi
- echo "+io" > "$(_cgroup2_base_dir)/cgroup.subtree_control"
-	echo "+io" > "$CGROUP2_DIR/cgroup.subtree_control"
+	THROTL_CLEAR_BASE_SUBTREE_CONTROL_IO=
+	THROTL_CLEAR_CGROUP2_DIR_CONTROL_IO=
+	if ! grep -q io "$(_cgroup2_base_dir)/cgroup.subtree_control"; then
+		echo "+io" > "$(_cgroup2_base_dir)/cgroup.subtree_control"
+		THROTL_CLEAR_BASE_SUBTREE_CONTROL_IO=true
+	fi
+	if ! grep -q io "$CGROUP2_DIR/cgroup.subtree_control"; then
+		echo "+io" > "$CGROUP2_DIR/cgroup.subtree_control"
+		THROTL_CLEAR_CGROUP2_DIR_CONTROL_IO=true
+	fi
mkdir -p "$CGROUP2_DIR/$THROTL_DIR"
  	return 0;
@@ -40,8 +50,12 @@ _set_up_throtl() {
_clean_up_throtl() {
  	rmdir "$CGROUP2_DIR/$THROTL_DIR"
-	echo "-io" > "$CGROUP2_DIR/cgroup.subtree_control"
-	echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control"
+	if [[ $THROTL_CLEAR_CGROUP2_DIR_CONTROL_IO == true ]]; then
+		echo "-io" > "$CGROUP2_DIR/cgroup.subtree_control"
+	fi
+	if [[ $THROTL_CLEAR_BASE_SUBTREE_CONTROL_IO == true ]]; then
+		echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control"
+	fi
_exit_cgroup2
  	_exit_null_blk






[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