From: Bart Van Assche <bvanassche@acm.org>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH blktests 2/3] Add I/O scheduler tests for queue depth 1
Date: Wed, 27 Apr 2022 14:31:42 -0700 [thread overview]
Message-ID: <20220427213143.2490653-3-bvanassche@acm.org> (raw)
In-Reply-To: <20220427213143.2490653-1-bvanassche@acm.org>
Some block devices, e.g. USB sticks, only support queue depth 1. The
QD=1 code paths do not get tested routinely. Hence add tests for the
QD=1 use case.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
common/rc | 5 ++++
tests/block/032 | 62 ++++++++++++++++++++++++++++++++++++++++++++
tests/block/032.out | 2 ++
tests/scsi/008 | 63 +++++++++++++++++++++++++++++++++++++++++++++
tests/scsi/008.out | 2 ++
5 files changed, 134 insertions(+)
create mode 100755 tests/block/032
create mode 100644 tests/block/032.out
create mode 100755 tests/scsi/008
create mode 100644 tests/scsi/008.out
diff --git a/common/rc b/common/rc
index 0528ce808256..2377e223aea7 100644
--- a/common/rc
+++ b/common/rc
@@ -321,6 +321,11 @@ _uptime_s() {
awk '{ print int($1) }' /proc/uptime
}
+# System uptime in centiseconds.
+_uptime_cs() {
+ sed 's/\.//;s/ .*//' /proc/uptime
+}
+
# Arguments: module to unload ($1) and retry count ($2).
unload_module() {
local i m=$1 rc=${2:-1}
diff --git a/tests/block/032 b/tests/block/032
new file mode 100755
index 000000000000..8b4d30282988
--- /dev/null
+++ b/tests/block/032
@@ -0,0 +1,62 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+. tests/block/rc
+. common/null_blk
+. common/iosched
+
+DESCRIPTION="test I/O scheduler performance of null_blk with queue_depth 1"
+QUICK=1
+
+requires() {
+ _have_null_blk
+}
+
+# Measure the time required to perform I/O on dev $1 with I/O scheduler $2.
+sched_time() {
+ local dev=$1 sched=$2
+ echo "$sched" > "/sys/block/$dev/queue/scheduler"
+ local start
+ start=$(_uptime_cs)
+ dd if="/dev/$dev" of=/dev/null bs=4K count=$((512 * 1024)) \
+ iflag=direct status=none &
+ dd of="/dev/$dev" if=/dev/zero bs=4K count=$((512 * 1024)) \
+ oflag=direct status=none &
+ wait
+ echo $(($(_uptime_cs) - start))
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ local params=(
+ hw_queue_depth=1
+ queue_mode=2
+ )
+ _init_null_blk "${params[@]}" || return 1
+
+ local dev=nullb0 fail status
+
+ none_time_cs=$(sched_time "$dev" none)
+ for sched in $(io_schedulers "$dev"); do
+ [ "$sched" = none ] && continue
+ time_cs=$(sched_time "$dev" "$sched")
+ if [ "$time_cs" -lt $(("$none_time_cs" * 110 / 100)) ]; then
+ status=pass
+ else
+ status=fail
+ fail=true
+ fi
+ TEST_RUN[$sched]="$time_cs vs $none_time_cs: $status"
+ done
+
+ _exit_null_blk
+
+ if [ -z "$fail" ]; then
+ echo "Test complete"
+ else
+ echo "Test failed"
+ return 1
+ fi
+}
diff --git a/tests/block/032.out b/tests/block/032.out
new file mode 100644
index 000000000000..3604e9e1e751
--- /dev/null
+++ b/tests/block/032.out
@@ -0,0 +1,2 @@
+Running block/032
+Test complete
diff --git a/tests/scsi/008 b/tests/scsi/008
new file mode 100755
index 000000000000..dec304fd29a2
--- /dev/null
+++ b/tests/scsi/008
@@ -0,0 +1,63 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+. tests/scsi/rc
+. common/iosched
+. common/scsi_debug
+
+DESCRIPTION="test I/O scheduler performance of scsi_debug with queue_depth 1"
+QUICK=1
+
+requires() {
+ _have_scsi_debug
+}
+
+# Measure the time required to perform I/O on dev $1 with I/O scheduler $2.
+sched_time() {
+ local dev=$1 sched=$2
+ echo "$sched" > "/sys/block/$dev/queue/scheduler"
+ local start
+ start=$(_uptime_cs)
+ dd if="/dev/$dev" of=/dev/null bs=4K count=$((512 * 1024)) \
+ iflag=direct status=none &
+ dd of="/dev/$dev" if=/dev/zero bs=4K count=$((512 * 1024)) \
+ oflag=direct status=none &
+ wait
+ echo $(($(_uptime_cs) - start))
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ local params=(
+ delay=0
+ dev_size_mb=2048
+ host_max_queue=1
+ )
+ _init_scsi_debug "${params[@]}" || return 1
+
+ local dev="${SCSI_DEBUG_DEVICES[0]}" fail
+
+ none_time_cs=$(sched_time "$dev" none)
+ for sched in $(io_schedulers "$dev"); do
+ [ "$sched" = none ] && continue
+ time_cs=$(sched_time "$dev" "$sched")
+ if [ "$time_cs" -lt $(("$none_time_cs" * 110 / 100)) ]; then
+ status=pass
+ else
+ status=fail
+ fail=true
+ fi
+ TEST_RUN[$sched]="$time_cs vs $none_time_cs: $status"
+ done
+
+ _exit_scsi_debug
+
+ if [ -z "$fail" ]; then
+ echo "Test complete"
+ else
+ echo "Test failed"
+ return 1
+ fi
+}
diff --git a/tests/scsi/008.out b/tests/scsi/008.out
new file mode 100644
index 000000000000..135bd5ae4b2d
--- /dev/null
+++ b/tests/scsi/008.out
@@ -0,0 +1,2 @@
+Running scsi/008
+Test complete
next prev parent reply other threads:[~2022-04-27 21:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 21:31 [PATCH blktests 0/3] Add QD=1 and gap zone tests Bart Van Assche
2022-04-27 21:31 ` [PATCH blktests 1/3] Introduce the io_schedulers() function Bart Van Assche
2022-04-28 3:50 ` Shinichiro Kawasaki
2022-04-28 19:53 ` Bart Van Assche
2022-04-27 21:31 ` Bart Van Assche [this message]
2022-04-28 6:27 ` [PATCH blktests 2/3] Add I/O scheduler tests for queue depth 1 Shinichiro Kawasaki
2022-04-28 19:52 ` Bart Van Assche
2022-05-09 10:56 ` Shinichiro Kawasaki
2022-04-27 21:31 ` [PATCH blktests 3/3] tests/scsi: Add tests for SCSI devices with gap zones Bart Van Assche
2022-04-28 0:39 ` Shinichiro Kawasaki
2022-04-28 3:16 ` Bart Van Assche
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=20220427213143.2490653-3-bvanassche@acm.org \
--to=bvanassche@acm.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox