diff mbox series

blktests: add block/039 for test updating nr_hw_queues vs switching elevator

Message ID 20250402041429.942623-1-ming.lei@redhat.com (mailing list archive)
State New
Headers show
Series blktests: add block/039 for test updating nr_hw_queues vs switching elevator | expand

Commit Message

Ming Lei April 2, 2025, 4:14 a.m. UTC
Add block/039 for covering updating nr_hw_queues and switching elevator.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 tests/block/039     | 67 +++++++++++++++++++++++++++++++++++++++++++++
 tests/block/039.out |  1 +
 2 files changed, 68 insertions(+)
 create mode 100755 tests/block/039
 create mode 100644 tests/block/039.out
diff mbox series

Patch

diff --git a/tests/block/039 b/tests/block/039
new file mode 100755
index 0000000..d29db45
--- /dev/null
+++ b/tests/block/039
@@ -0,0 +1,67 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2025 Ming Lei <ming.lei@redhat.com>
+#
+# Most of code is copied from block/029
+#
+# Trigger blk_mq_update_nr_hw_queues() & elevator switch
+
+. tests/block/rc
+. common/null_blk
+
+DESCRIPTION="test blk_mq_update_nr_hw_queues() vs switch elevator"
+QUICK=1
+
+requires() {
+	_have_fio && _have_null_blk
+}
+
+
+modify_io_sched() {
+	local deadline
+	local dev=$1
+
+	deadline=$(($(_uptime_s) + TIMEOUT))
+	while [ "$(_uptime_s)" -lt "$deadline" ]; do
+		for sched in $(_io_schedulers "$dev"); do
+			echo "$sched" > /sys/block/"$dev"/queue/scheduler > /dev/null 2>&1
+			sleep .5
+		done
+	done
+}
+
+modify_nr_hw_queues() {
+	local deadline num_cpus
+
+	deadline=$(($(_uptime_s) + TIMEOUT))
+	num_cpus=$(nproc)
+	while [ "$(_uptime_s)" -lt "$deadline" ]; do
+		sleep .1
+		echo 1 > /sys/kernel/config/nullb/nullb1/submit_queues
+		sleep .1
+		echo "$num_cpus" > /sys/kernel/config/nullb/nullb1/submit_queues
+	done
+}
+
+test() {
+	local sq=/sys/kernel/config/nullb/nullb1/submit_queues
+
+	: "${TIMEOUT:=30}"
+	_configure_null_blk nullb1 completion_nsec=0 blocksize=512 \
+			    size=16 memory_backed=1 power=1 &&
+	if { echo 1 >$sq; } 2>/dev/null; then
+		modify_nr_hw_queues &
+		modify_io_sched nullb1 &
+		fio --rw=randwrite --bs=4K --loops=$((10**6)) \
+		    --iodepth=64 --group_reporting --sync=1 --direct=1 \
+		    --ioengine=libaio --filename="/dev/nullb1" \
+		    --runtime="${TIMEOUT}" --name=nullb1 \
+		    --output="${RESULTS_DIR}/block/fio-output-029.txt" \
+		    >>"$FULL"
+		wait
+	else
+		echo "Skipping test because $sq cannot be modified" >>"$FULL"
+	fi
+	_exit_null_blk
+	echo Passed
+}
diff --git a/tests/block/039.out b/tests/block/039.out
new file mode 100644
index 0000000..863339f
--- /dev/null
+++ b/tests/block/039.out
@@ -0,0 +1 @@ 
+Passed