Skip to contentSkip to conversation

tests/throtl: add a new test 009

PATCH Applied Tao Cui 2 participants 2 messages Aug 25 – Sep 3 Block layer

lore
Share & tools
lore

Tao Cui

author
#0 lore raw

PATCH v2 1/1 tests/throtl: add a new test 009

From: Tao Cui <[email protected]>

Test the boundary condition of removing a cgroup while it still has IO queued in the blk-throttle queue. The queued bios must be flushed through without any blk-cgroup or blk-throttle warning.

The dmesg check matches any blk-cgroup / blk-throttle warning rather than a single call site, so it is not tied to one symbol.

---
Changes since v1 [1]:
- Add a Link: tag referring to the background discussion, as suggested by Shin'ichiro.
- Drop THROTL_BLKDEV_TYPES=nullb so the test runs for both nullb and scsi_debug like the other throtl test cases, as suggested by Shin'ichiro.

See also the blkcg "store blkcg in bio" RFC:
https://lore.kernel.org/r/[email protected]

 tests/throtl/009     | 64 ++++++++++++++++++++++++++++++++++++++++++++
 tests/throtl/009.out |  2 ++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/throtl/009
 create mode 100644 tests/throtl/009.out
tests/throtl/009 new file +64 -0
new file mode 100755
index 0000000..d304301
@@ -0,0 +1,64 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2026 Tao Cui <[email protected]>
+#
+# Regression test for removing a cgroup while IO is still queued in the
+# blk-throttle queue.  The queued bios must be flushed without any
+# blk-cgroup or blk-throttle warning.
+
+. tests/throtl/rc
+
+DESCRIPTION="queued throttled IO vs. cgroup removal must not warn"
+QUICK=1
+
+set_conditions() {
+	_set_throtl_blkdev_type "$@"
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	if ! _set_up_throtl; then
+		return 1
+	fi
+
+	# Throttle reads so the bio queues.
+	_throtl_set_limits rbps=4096
+
+	(
+		echo "$BASHPID" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs"
+		exec dd if=/dev/"$THROTL_DEV" of=/dev/null bs=1M count=1 status=none
+	) &
+	local io_pid=$!
+	sleep 2
+
+	# Move the reader to the cgroup2 root so the throttle cgroup can be
+	# removed while its bio is still queued.  $CGROUP2_DIR has +io in its
+	# subtree_control and so cannot hold processes.
+	echo "$io_pid" > "$(_cgroup2_base_dir)/cgroup.procs"
+
+	# Remove the throttle cgroup while its bio is still queued.
+	rmdir "$CGROUP2_DIR/$THROTL_DIR"
+	sleep 3
+
+	kill "$io_pid" 2>/dev/null
+	wait "$io_pid" 2>/dev/null
+
+	# $THROTL_DIR is already gone; tear down the rest by hand.
+	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_throtl_blkdev
+
+	if _dmesg_since_test_start | grep -qE "WARNING:.*(blk-cgroup|blk-throttle)"; then
+		echo "WARNING: blkcg/blk-throttle warning on cgroup removal with queued IO"
+		_dmesg_since_test_start | grep -A 12 -E "WARNING:.*(blk-cgroup|blk-throttle)" \
+			>> "$FULL"
+	fi
+
+	echo "Test complete"
+}
tests/throtl/009.out new file +2 -0
new file mode 100644
index 0000000..be675dd
@@ -0,0 +1,2 @@
+Running throtl/009
+Test complete
Signature · 1 line
2.43.0
#1 lore raw
Quoted 10 lines · Tao Cui

From: Tao Cui <[email protected]>

Test the boundary condition of removing a cgroup while it still has IO queued in the blk-throttle queue. The queued bios must be flushed through without any blk-cgroup or blk-throttle warning.

The dmesg check matches any blk-cgroup / blk-throttle warning rather than a single call site, so it is not tied to one symbol.

I applied the patch. Thanks!