All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-block@vger.kernel.org,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH blktests v2 2/2] Add a test that triggers blk_mq_update_nr_hw_queues()
Date: Thu, 24 Oct 2019 14:03:52 -0700	[thread overview]
Message-ID: <20191024210352.71080-3-bvanassche@acm.org> (raw)
In-Reply-To: <20191024210352.71080-1-bvanassche@acm.org>

Note: the newly added test script only triggers blk_mq_update_nr_hw_queues()
for kernel versions that include commit 45919fbfe1c4 ("null_blk: Enable
modifying 'submit_queues' after an instance has been configured").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 tests/block/029     | 64 +++++++++++++++++++++++++++++++++++++++++++++
 tests/block/029.out |  1 +
 2 files changed, 65 insertions(+)
 create mode 100755 tests/block/029
 create mode 100644 tests/block/029.out

diff --git a/tests/block/029 b/tests/block/029
new file mode 100755
index 000000000000..d298bac8db5c
--- /dev/null
+++ b/tests/block/029
@@ -0,0 +1,64 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2019 Google LLC
+#
+# Trigger blk_mq_update_nr_hw_queues().
+
+. tests/block/rc
+. common/null_blk
+
+DESCRIPTION="trigger blk_mq_update_nr_hw_queues()"
+QUICK=1
+
+requires() {
+	_have_null_blk
+}
+
+# Configure one null_blk instance.
+configure_null_blk() {
+	local nullb0="/sys/kernel/config/nullb/nullb0"
+
+	mkdir "$nullb0" &&
+	echo 0 > "$nullb0/completion_nsec" &&
+	echo 512 > "$nullb0/blocksize" &&
+	echo 16 > "$nullb0/size" &&
+	echo 1 > "$nullb0/memory_backed" &&
+	echo 1 > "$nullb0/power" &&
+	ls -l /dev/nullb* &>>"$FULL"
+}
+
+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/nullb0/submit_queues
+		sleep .1
+		echo "$num_cpus" > /sys/kernel/config/nullb/nullb0/submit_queues
+	done
+}
+
+test() {
+	local sq=/sys/kernel/config/nullb/nullb0/submit_queues
+
+	: "${TIMEOUT:=30}"
+	_init_null_blk nr_devices=0 queue_mode=2 &&
+	configure_null_blk
+	if { echo 1 >$sq; } 2>/dev/null; then
+		modify_nr_hw_queues &
+		fio --rw=randwrite --bs=4K --loops=$((10**6)) \
+		    --iodepth=64 --group_reporting --sync=1 --direct=1 \
+		    --ioengine=libaio --filename="/dev/nullb0" \
+		    --runtime="${TIMEOUT}" --name=nullb0 \
+		    --output="${RESULTS_DIR}/block/fio-output-029.txt" \
+		    >>"$FULL"
+		wait
+	else
+		echo "Skipping test because $sq cannot be modified" >>"$FULL"
+	fi
+	rmdir /sys/kernel/config/nullb/nullb0
+	_exit_null_blk
+	echo Passed
+}
diff --git a/tests/block/029.out b/tests/block/029.out
new file mode 100644
index 000000000000..863339fb8ced
--- /dev/null
+++ b/tests/block/029.out
@@ -0,0 +1 @@
+Passed
-- 
2.24.0.rc0.303.g954a862665-goog


  parent reply	other threads:[~2019-10-24 21:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 21:03 [PATCH blktests v2 0/2] Add a test that triggers blk_mq_update_nr_hw_queues() Bart Van Assche
2019-10-24 21:03 ` [PATCH blktests v2 1/2] Move and rename uptime_s() Bart Van Assche
2019-10-24 21:03 ` Bart Van Assche [this message]
2019-10-30 20:45 ` [PATCH blktests v2 0/2] Add a test that triggers blk_mq_update_nr_hw_queues() Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191024210352.71080-3-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.