Skip to content

Commit

Permalink
throtl: set "io" to subtree_control only if required
Browse files Browse the repository at this point in the history
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@redhat.com>
Link: #149
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
  • Loading branch information
kawasaki committed Nov 19, 2024
1 parent 222cd54 commit 4e22221
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/throtl/rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,17 +33,29 @@ _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;
}

_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
Expand Down

0 comments on commit 4e22221

Please sign in to comment.