Skip to contentSkip to conversation

tests/throtl: add a new test 006

PATCH In review Ming Lei 3 participants 3 messages Mar 4, 2025 – Mar 5, 2025 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

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

Add test for covering prioritized meta IO when throttling, regression test for commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata").

---
V2:
- add ext4 jbd2 task into the cgroup(Kuai)
- use 4M size IO(Kuai)

 tests/throtl/006     | 62 ++++++++++++++++++++++++++++++++++++++++++++
 tests/throtl/006.out |  4 +++
 tests/throtl/rc      | 19 ++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100755 tests/throtl/006
 create mode 100644 tests/throtl/006.out
tests/throtl/006 new file +62 -0
new file mode 100755
index 0000000..23b30dc
@@ -0,0 +1,62 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Ming Lei
+#
+# Test prioritized meta IO when IO throttling, regression test for
+# commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata")
+
+. tests/throtl/rc
+
+DESCRIPTION="test if meta IO has higher priority than data IO"
+QUICK=1
+
+requires() {
+	_have_program mkfs.ext4
+}
+
+test_meta_io() {
+	local path="$1"
+	local start_time
+	local end_time
+	local elapsed
+
+	start_time=$(date +%s.%N)
+	mkdir "${path}"/xxx
+	touch "${path}"/xxx/1
+	sync "${path}"/xxx
+
+	end_time=$(date +%s.%N)
+	elapsed=$(echo "$end_time - $start_time" | bc)
+	printf "%.0f\n" "$elapsed"
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	if ! _set_up_throtl memory_backed=1; then
+		return 1;
+	fi
+
+	mkdir -p "${TMPDIR}/mnt"
+	mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 -F "/dev/${THROTL_DEV}" >> "$FULL" 2>&1
+	mount "/dev/${THROTL_DEV}" "${TMPDIR}/mnt" >> "$FULL" 2>&1
+
+	_throtl_set_limits wbps=$((1024 * 1024))
+	{
+		local jbd2_pid
+
+		jbd2_pid=$(ps -eo pid,comm | pgrep -f "jbd2/${THROTL_DEV}" | awk '{print $1}')
+		echo "$BASHPID" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs"
+		echo "$jbd2_pid" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs"
+		_throtl_issue_fs_io  "${TMPDIR}/mnt/test.img" write 4M 1 &
+		sleep 2
+		test_meta_io "${TMPDIR}/mnt"
+		wait
+	} &
+	wait $!
+
+	umount "${TMPDIR}/mnt" || return $?
+	_throtl_remove_limits
+	_clean_up_throtl
+	echo "Test complete"
+}
tests/throtl/006.out new file +4 -0
new file mode 100644
index 0000000..8c3d176
@@ -0,0 +1,4 @@
+Running throtl/006
+0
+4
+Test complete
tests/throtl/rc +19 -0
index df54cb9..327084b 100644
@@ -75,6 +75,25 @@ _throtl_get_max_io_size() {
 	cat "/sys/block/$THROTL_DEV/queue/max_sectors_kb"
 }
 
+_throtl_issue_fs_io() {
+	local path=$1
+	local start_time
+	local end_time
+	local elapsed
+
+	start_time=$(date +%s.%N)
+
+	if [ "$2" == "read" ]; then
+		dd if="${path}" of=/dev/null bs="$3" count="$4" iflag=direct status=none
+	elif [ "$2" == "write" ]; then
+		dd of="${path}" if=/dev/zero bs="$3" count="$4" oflag=direct conv=fdatasync status=none
+	fi
+
+	end_time=$(date +%s.%N)
+	elapsed=$(echo "$end_time - $start_time" | bc)
+	printf "%.0f\n" "$elapsed"
+}
+
 _throtl_issue_io() {
 	local start_time
 	local end_time
Signature · 1 line
2.47.1
Reviewed-by on v2 1/1
#1 lore raw

Hi,

Quoted 11 lines · Ming Lei

Add test for covering prioritized meta IO when throttling, regression test for commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata").

---
V2:
- add ext4 jbd2 task into the cgroup(Kuai)
- use 4M size IO(Kuai)

Quoted 7 lines
  tests/throtl/006     | 62 ++++++++++++++++++++++++++++++++++++++++++++
  tests/throtl/006.out |  4 +++
  tests/throtl/rc      | 19 ++++++++++++++
  3 files changed, 85 insertions(+)

create mode 100755 tests/throtl/006
create mode 100644 tests/throtl/006.out

LGTM, just one nit below:

Quoted 10 lines
tests/throtl/006 new file +4 -0
new file mode 100755
index 0000000..23b30dc
@@ -0,0 +1,62 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Ming Lei
+#

tests/throtl/006 line 14

Quoted 10 lines
tests/throtl/006 new file +10 -0
+# Test prioritized meta IO when IO throttling, regression test for
+# commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata")
+
+. tests/throtl/rc
+
+DESCRIPTION="test if meta IO has higher priority than data IO"
+QUICK=1
+
+requires() {
+	_have_program mkfs.ext4

Perhaps also add
_have_kernel_option EXT4_FS

feel free to add:

Quoted 89 lines
tests/throtl/006 new file +48 -0
+}
+
+test_meta_io() {
+	local path="$1"
+	local start_time
+	local end_time
+	local elapsed
+
+	start_time=$(date +%s.%N)
+	mkdir "${path}"/xxx
+	touch "${path}"/xxx/1
+	sync "${path}"/xxx
+
+	end_time=$(date +%s.%N)
+	elapsed=$(echo "$end_time - $start_time" | bc)
+	printf "%.0f\n" "$elapsed"
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	if ! _set_up_throtl memory_backed=1; then
+		return 1;
+	fi
+
+	mkdir -p "${TMPDIR}/mnt"
+	mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 -F "/dev/${THROTL_DEV}" >> "$FULL" 2>&1
+	mount "/dev/${THROTL_DEV}" "${TMPDIR}/mnt" >> "$FULL" 2>&1
+
+	_throtl_set_limits wbps=$((1024 * 1024))
+	{
+		local jbd2_pid
+
+		jbd2_pid=$(ps -eo pid,comm | pgrep -f "jbd2/${THROTL_DEV}" | awk '{print $1}')
+		echo "$BASHPID" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs"
+		echo "$jbd2_pid" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs"
+		_throtl_issue_fs_io  "${TMPDIR}/mnt/test.img" write 4M 1 &
+		sleep 2
+		test_meta_io "${TMPDIR}/mnt"
+		wait
+	} &
+	wait $!
+
+	umount "${TMPDIR}/mnt" || return $?
+	_throtl_remove_limits
+	_clean_up_throtl
+	echo "Test complete"
+}
tests/throtl/006.out new file +4 -0
new file mode 100644
index 0000000..8c3d176
@@ -0,0 +1,4 @@
+Running throtl/006
+0
+4
+Test complete
tests/throtl/rc +19 -0
index df54cb9..327084b 100644
@@ -75,6 +75,25 @@ _throtl_get_max_io_size() {
  	cat "/sys/block/$THROTL_DEV/queue/max_sectors_kb"
  }
 
+_throtl_issue_fs_io() {
+	local path=$1
+	local start_time
+	local end_time
+	local elapsed
+
+	start_time=$(date +%s.%N)
+
+	if [ "$2" == "read" ]; then
+		dd if="${path}" of=/dev/null bs="$3" count="$4" iflag=direct status=none
+	elif [ "$2" == "write" ]; then
+		dd of="${path}" if=/dev/zero bs="$3" count="$4" oflag=direct conv=fdatasync status=none
+	fi
+
+	end_time=$(date +%s.%N)
+	elapsed=$(echo "$end_time - $start_time" | bc)
+	printf "%.0f\n" "$elapsed"
+}
+
  _throtl_issue_io() {
  	local start_time
  	local end_time
#2 lore raw
Quoted 6 lines · Yu Kuai

Hi,

Quoted 3 lines · Ming Lei

Add test for covering prioritized meta IO when throttling, regression test for commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata").

Thank you Ming for this v2 patch. I reverted the commit 29390bb5661d from the kernel v6.14-rc5, and confirmed the test case fails.

Quoted 33 lines
Quoted 8 lines

---
V2:
- add ext4 jbd2 task into the cgroup(Kuai)
- use 4M size IO(Kuai)

Quoted 7 lines
  tests/throtl/006     | 62 ++++++++++++++++++++++++++++++++++++++++++++
  tests/throtl/006.out |  4 +++
  tests/throtl/rc      | 19 ++++++++++++++
  3 files changed, 85 insertions(+)

create mode 100755 tests/throtl/006
create mode 100644 tests/throtl/006.out

LGTM, just one nit below:

Quoted 15 lines
tests/throtl/006 new file +9 -0
new file mode 100755
index 0000000..23b30dc
@@ -0,0 +1,62 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Ming Lei
+#
+# Test prioritized meta IO when IO throttling, regression test for
+# commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata")
+
+. tests/throtl/rc
+
Quoted 8 lines

tests/throtl/006 line 14

Quoted 5 lines
tests/throtl/006 new file +5 -0
+DESCRIPTION="test if meta IO has higher priority than data IO"
+QUICK=1
+
+requires() {
+	_have_program mkfs.ext4

Perhaps also add
_have_kernel_option EXT4_FS

That's a good improvement. "_have_driver ext4" does the same check and is a bit shorter. So I folded it in.

Quoted 3 lines

feel free to add:

FYI, I applied the patch, folding in my nit comments for the v1 patch also.

Thanks!