Skip to contentSkip to conversation

block/021: test setting 'nr_requests'

PATCH In review Ming Lei 2 participants 2 messages Jun 2, 2018 – Jun 11, 2018 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block/021: test setting 'nr_requests'

'nr_requests' can be a bit different for 'none' scheduler, and especially current blk-mq can only decrease this value for 'none.'

The patch of 'blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler' has been sent out for fixing this issue.

Cc Marco Patalano <[email protected]>
Cc "Ewan D. Milne" <[email protected]>
---
 tests/block/021     | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/block/021.out |  2 ++
 2 files changed, 53 insertions(+)
 create mode 100755 tests/block/021
 create mode 100755 tests/block/021.out
tests/block/021 new file +51 -0
new file mode 100755
index 000000000000..b72d9bd8b41d
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Test blk-mq request allocation when hardware tags are limited. Regression
+# test for commit e6fc46498784 ("blk-mq: avoid starving tag allocation after
+# allocating process migrates").
+#
+# Copyright (C) 2018 Ming Lei <[email protected]>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+DESCRIPTION="read/write nr_requests on null-blk with different scheduler"
+QUICK=1
+
+requires() {
+	_have_module null_blk
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	modprobe -r null_blk
+	modprobe null_blk
+
+	local scheds
+	# shellcheck disable=SC2207
+	scheds=($(sed 's/[][]//g' /sys/block/nullb0/queue/scheduler))
+
+	for sched in "${scheds[@]}"; do
+		echo "Testing $sched" >> "$FULL"
+		echo "$sched" > /sys/block/nullb0/queue/scheduler
+		max_nr=`cat /sys/block/nullb0/queue/nr_requests`
+		for nr in `seq 4 $max_nr`; do
+			echo $nr > /sys/block/nullb0/queue/nr_requests
+		done
+	done
+
+	modprobe -r null_blk
+
+	echo "Test complete"
+}
tests/block/021.out new file +2 -0
new file mode 100755
index 000000000000..3a397c5c8ff5
@@ -0,0 +1,2 @@
+Running block/021
+Test complete
Signature · 1 line
2.9.5
#1 lore raw
Quoted 6 lines · Ming Lei

'nr_requests' can be a bit different for 'none' scheduler, and especially current blk-mq can only decrease this value for 'none.'

The patch of 'blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler' has been sent out for fixing this issue.

Applied with a couple of fixes mentioned below.

Quoted 16 lines
Cc Marco Patalano <[email protected]>
Cc "Ewan D. Milne" <[email protected]>
---
 tests/block/021     | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/block/021.out |  2 ++
 2 files changed, 53 insertions(+)
 create mode 100755 tests/block/021
 create mode 100755 tests/block/021.out
tests/block/021 new file +0 -0
new file mode 100755
index 000000000000..b72d9bd8b41d

tests/block/021 line 5

Quoted 5 lines
tests/block/021 new file +5 -0
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Test blk-mq request allocation when hardware tags are limited. Regression
+# test for commit e6fc46498784 ("blk-mq: avoid starving tag allocation after
+# allocating process migrates").

This wasn't updated for this test. I fixed it.

Quoted 26 lines
tests/block/021 new file +26 -0
+# Copyright (C) 2018 Ming Lei <[email protected]>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+DESCRIPTION="read/write nr_requests on null-blk with different scheduler"
+QUICK=1
+
+requires() {
+	_have_module null_blk
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	modprobe -r null_blk

tests/block/021 line 42

Quoted 10 lines
tests/block/021 new file +10 -0
+	modprobe null_blk
+
+	local scheds
+	# shellcheck disable=SC2207
+	scheds=($(sed 's/[][]//g' /sys/block/nullb0/queue/scheduler))
+
+	for sched in "${scheds[@]}"; do
+		echo "Testing $sched" >> "$FULL"
+		echo "$sched" > /sys/block/nullb0/queue/scheduler
+		max_nr=`cat /sys/block/nullb0/queue/nr_requests`

I changed this to the preferred $() style command substitution.

tests/block/021 line 43

Quoted 1 line
tests/block/021 new file +1 -0
+		for nr in `seq 4 $max_nr`; do

I changed this to the preferred bash for loop syntax.

Quoted 19 lines
tests/block/021 new file +8 -0
+			echo $nr > /sys/block/nullb0/queue/nr_requests
+		done
+	done
+
+	modprobe -r null_blk
+
+	echo "Test complete"
+}
tests/block/021.out new file +2 -0
new file mode 100755
index 000000000000..3a397c5c8ff5
@@ -0,0 +1,2 @@
+Running block/021
+Test complete
Signature · 1 line
2.9.5