Add a test that triggers blk_mq_update_nr_hw_queues()
cover Add a test that triggers blk_mq_update_nr_hw_queues()
Hi Omar,
This patch series includes the test that I used to verify my recently posted blk_mq_update_nr_hw_queues() patches. Please consider these patches for inclusion in the blktests repository.
Thanks,
Bart.
Bart Van Assche (2):
Move and rename uptime_s()
Add a test that triggers blk_mq_update_nr_hw_queues()
common/multipath-over-rdma | 9 +----- common/rc | 9 ++++++ tests/block/029 | 63 ++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 1 + tests/nvmeof-mp/rc | 2 +- tests/srp/014 | 2 +- tests/srp/rc | 2 +- 7 files changed, 77 insertions(+), 11 deletions(-) create mode 100755 tests/block/029 create mode 100644 tests/block/029.out
PATCH 1/2 Move and rename uptime_s()
Make it easy to use the uptime_s() function from block tests.
--- common/multipath-over-rdma | 9 +-------- common/rc | 9 +++++++++ tests/nvmeof-mp/rc | 2 +- tests/srp/014 | 2 +- tests/srp/rc | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-)
common/multipath-over-rdma +1 -8
@@ -129,19 +129,12 @@ held_by() { done } -# System uptime in seconds. -uptime_s() { - local a b - - echo "$(</proc/uptime)" | { read -r a b && echo "${a%%.*}"; } -} - # Sleep until either $1 seconds have elapsed or until the deadline $2 has been # reached. Return 1 if and only if the deadline has been met. sleep_until() { local duration=$1 deadline=$2 u - u=$(uptime_s) + u=$(_uptime_s) if [ $((u + duration)) -le "$deadline" ]; then sleep "$duration" else
common/rc +9 -0
@@ -246,3 +246,12 @@ _test_dev_is_partition() { _filter_xfs_io_error() { sed -e 's/^\(.*\)64\(: .*$\)/\1\2/' } + +# System uptime in seconds. +_uptime_s() { + local a b + + echo "$(</proc/uptime)" | { + read -r a b && echo "$b" >/dev/null && echo "${a%%.*}"; + } +}
tests/nvmeof-mp/rc +1 -1
@@ -113,7 +113,7 @@ simulate_network_failure_loop() { [ -e "$dev" ] || return $? [ -n "$duration" ] || return $? - deadline=$(($(uptime_s) + duration)) + deadline=$(($(_uptime_s) + duration)) while [ $rc = 0 ]; do sleep_until 5 ${deadline} || break for d in $(held_by "$dev"); do
tests/srp/014 +1 -1
@@ -69,7 +69,7 @@ sg_reset_loop() { [ -e "$dev" ] || return $? [ -n "$duration" ] || return $? reset_type=(-d -b) - deadline=$(($(uptime_s) + duration)) + deadline=$(($(_uptime_s) + duration)) while true; do sleep_until 1 ${deadline} || break cmd="sg_reset --no-esc ${reset_type[i++ % 2]} $dev"
tests/srp/rc +1 -1
@@ -247,7 +247,7 @@ simulate_network_failure_loop() { [ -e "$dev" ] || return $? [ -n "$duration" ] || return $? - deadline=$(($(uptime_s) + duration)) + deadline=$(($(_uptime_s) + duration)) s=5 while [ $rc = 0 ]; do sleep_until 5 ${deadline} || break
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
PATCH 2/2 Add a test that triggers blk_mq_update_nr_hw_queues()
In reply to Bart Van Assche--- tests/block/029 | 63 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 1 + 2 files changed, 64 insertions(+) create mode 100755 tests/block/029 create mode 100644 tests/block/029.out
tests/block/029 new file +63 -0
@@ -0,0 +1,63 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2019 Google Inc. +# +# 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() { + ( + cd /sys/kernel/config/nullb || return $? + ( + mkdir -p nullb0 && + cd nullb0 && + echo 0 > completion_nsec && + echo 512 > blocksize && + echo 16 > size && + echo 1 > memory_backed && + echo 1 > power + ) + ) && + ls -l /dev/nullb* &>>"$FULL" +} + +modify_nr_hw_queues() { + local deadline num_cpus + + deadline=$(($(_uptime_s) + TIMEOUT)) + num_cpus=$(find /sys/devices/system/cpu -maxdepth 1 -name 'cpu[0-9]*' | + wc -l) + 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() { + : "${TIMEOUT:=30}" + _init_null_blk nr_devices=0 queue_mode=2 && + configure_null_blk + 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 + rmdir /sys/kernel/config/nullb/nullb0 + _exit_null_blk + echo Passed +}
tests/block/029.out new file +1 -0
@@ -0,0 +1 @@ +Passed
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
Re: [PATCH blktests 1/2] Move and rename uptime_s()
In reply to Bart Van AsscheLook good.
Quoted 3 lines · Bart Van Assche
Make it easy to use the
uptime_s()function from block tests.Signed-off-by Bart Van Assche<[email protected]>
Look good.
Quoted 85 lines · Bart Van Assche
Signed-off-by Bart Van Assche <[email protected]>--- tests/block/029 | 63 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 1 + 2 files changed, 64 insertions(+)create mode 100755 tests/block/029
create mode 100644 tests/block/029.outtests/block/029 new file +63
-0@@ -0,0 +1,63 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2019 Google Inc. +# +# 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() { + ( + cd /sys/kernel/config/nullb || return $? + ( + mkdir -p nullb0 && + cd nullb0 && + echo 0 > completion_nsec && + echo 512 > blocksize && + echo 16 > size && + echo 1 > memory_backed && + echo 1 > power + ) + ) && + ls -l /dev/nullb* &>>"$FULL" +} + +modify_nr_hw_queues() { + local deadline num_cpus + + deadline=$(($(_uptime_s) + TIMEOUT)) + num_cpus=$(find /sys/devices/system/cpu -maxdepth 1 -name 'cpu[0-9]*' | + wc -l) + 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() { + : "${TIMEOUT:=30}" + _init_null_blk nr_devices=0 queue_mode=2 && + configure_null_blk + 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 + rmdir /sys/kernel/config/nullb/nullb0 + _exit_null_blk + echo Passed +}tests/block/029.out new file +1
-0@@ -0,0 +1 @@ +Passed
Re: [PATCH blktests 1/2] Move and rename uptime_s()
In reply to Bart Van AsscheQuoted 41 lines · Bart Van Assche
Make it easy to use the
uptime_s()function from block tests.Signed-off-by Bart Van Assche <[email protected]>--- common/multipath-over-rdma | 9 +-------- common/rc | 9 +++++++++ tests/nvmeof-mp/rc | 2 +- tests/srp/014 | 2 +- tests/srp/rc | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-)common/multipath-over-rdma +1
-8@@ -129,19 +129,12 @@ held_by() { done } -# System uptime in seconds. -uptime_s() { - local a b - - echo "$(</proc/uptime)" | { read -r a b && echo "${a%%.*}"; } -} - # Sleep until either $1 seconds have elapsed or until the deadline $2 has been # reached. Return 1 if and only if the deadline has been met. sleep_until() { local duration=$1 deadline=$2 u - u=$(uptime_s) + u=$(_uptime_s) if [ $((u + duration)) -le "$deadline" ]; then sleep "$duration" elsecommon/rc +0
-0
common/rc _test_dev_is_partition() { · line 254
Quoted 9 lines
common/rc +6
-0@@ -246,3 +246,12 @@ _test_dev_is_partition() { _filter_xfs_io_error() { sed -e 's/^\(.*\)64\(: .*$\)/\1\2/' } + +# System uptime in seconds. +_uptime_s() { + local a b + + echo "$(</proc/uptime)" | {
What's wrong with cat /proc/uptime? Or even better,
{ read ... } < /proc/uptime
common/rc _test_dev_is_partition() { · line 255
Quoted 1 line
common/rc +1
-0+ read -r a b && echo "$b" >/dev/null && echo "${a%%.*}";
What's the point of the echo "$b" here? Seems like this could all be condensed to:
{ read -r s && echo "${s%%.*}" } < /proc/uptimeBut that's more cryptic than it needs to be. Can we just do:
awk '{ print int($1) }' /proc/uptime
Re: [PATCH blktests 1/2] Move and rename uptime_s()
Quoted 10 lines · Omar Sandoval
common/rc _test_dev_is_partition() { · line 254
Quoted 5 lines · Bart Van Assche
common/rc +5
-0+# System uptime in seconds. +_uptime_s() { + local a b + + echo "$(</proc/uptime)" | {What's wrong with cat
/proc/uptime? Or even better,{ read ... } < /proc/uptime
Hi Omar,
As you probably know 'cat' triggers a fork() system call but echo $(<...) not. This is a performance optimization. Input redirection would also work.
Quoted 3 lines
common/rc _test_dev_is_partition() { · line 255
Quoted 1 line
common/rc +1
-0+ read -r a b && echo "$b" >/dev/null && echo "${a%%.*}";What's the point of the echo "$b" here?
That echo "$b" statement suppresses a shellcheck warning about $b not being used.
Quoted 7 lines
Seems like this could all be condensed to:
{ read -r s && echo "${s%%.*}" } < /proc/uptimeBut that's more cryptic than it needs to be. Can we just do:
awk '{ print int($1) }' /proc/uptime
That's a valid alternative, but an alternative that triggers a fork() system call. I don't have a strong opinion about which alternative to choose. Do you perhaps have a preference?
Thanks,
Bart.
Quoted 35 lines · Bart Van Assche
Signed-off-by Bart Van Assche <[email protected]>--- tests/block/029 | 63 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 1 + 2 files changed, 64 insertions(+) create mode 100755 tests/block/029 create mode 100644 tests/block/029.outtests/block/029 new file +21
-0@@ -0,0 +1,63 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2019 Google Inc. +# +# 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() { + ( + cd /sys/kernel/config/nullb || return $? + (
tests/block/029 line 31
Quoted 10 lines
tests/block/029 new file +10
-0+ mkdir -p nullb0 && + cd nullb0 && + echo 0 > completion_nsec && + echo 512 > blocksize && + echo 16 > size && + echo 1 > memory_backed && + echo 1 > power + ) + ) && + ls -l /dev/nullb* &>>"$FULL"
What's the point of these nested subshells? Can't this just be:
configure_null_blk() {
cd /sys/kernel/config/nullb &&
mkdir -p nullb0 &&
cd nullb0 &&
echo 0 > completion_nsec &&
echo 512 > blocksize &&
echo 16 > size &&
echo 1 > memory_backed &&
echo 1 > power &&
ls -l /dev/nullb* &>>"$FULL"
}tests/block/029 line 39
Quoted 8 lines
tests/block/029 new file +8
-0+} + +modify_nr_hw_queues() { + local deadline num_cpus + + deadline=$(($(_uptime_s) + TIMEOUT)) + num_cpus=$(find /sys/devices/system/cpu -maxdepth 1 -name 'cpu[0-9]*' | + wc -l)
Please just use nproc. Or even better, can you just read the original value of /sys/kernel/config/nullb/nullb0/submit_queues? Or does that start at 1?
Quoted 34 lines
tests/block/029 new file +24
-0+ 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() { + : "${TIMEOUT:=30}" + _init_null_blk nr_devices=0 queue_mode=2 && + configure_null_blk + 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 + rmdir /sys/kernel/config/nullb/nullb0 + _exit_null_blk + echo Passed +}tests/block/029.out new file +1
-0@@ -0,0 +1 @@ +PassedSignature · 1 line
2.23.0.866.gb869b98d4c-goog
Re: [PATCH blktests 1/2] Move and rename uptime_s()
In reply to Bart Van AsscheQuoted 28 lines · Bart Van Assche
Quoted 10 lines · Omar Sandoval
common/rc _test_dev_is_partition() { · line 254
Quoted 5 lines · Bart Van Assche
common/rc +5
-0+# System uptime in seconds. +_uptime_s() { + local a b + + echo "$(</proc/uptime)" | {What's wrong with cat
/proc/uptime? Or even better,{ read ... } < /proc/uptimeHi Omar,
As you probably know 'cat' triggers a
fork()system call but echo $(<...) not. This is a performance optimization. Input redirection would also work.Quoted 3 lines
common/rc _test_dev_is_partition() { · line 255
Quoted 1 line
common/rc +1
-0+ read -r a b && echo "$b" >/dev/null && echo "${a%%.*}";What's the point of the echo "$b" here?
That echo "$b" statement suppresses a shellcheck warning about $b not being used.
Quoted 4 lines
Seems like this could all be condensed to:
{ read -r s && echo "${s%%.*}" } < /proc/uptime
Quoted 7 lines
Quoted 3 lines
But that's more cryptic than it needs to be. Can we just do:
awk '{ print int($1) }' /proc/uptimeThat's a valid alternative, but an alternative that triggers a
fork()system call. I don't have a strong opinion about which alternative to choose. Do you perhaps have a preference?
The awk option is more readable, and we're not trying to win any performance awards in blktests. Let's just go with that.
Quoted 19 lines · Omar Sandoval
Quoted 5 lines · Bart Van Assche
tests/block/029 new file +5
-0+# Configure one null_blk instance. +configure_null_blk() { + ( + cd /sys/kernel/config/nullb || return $? + (tests/block/029 line 31
Quoted 10 lines
tests/block/029 new file +10
-0+ mkdir -p nullb0 && + cd nullb0 && + echo 0 > completion_nsec && + echo 512 > blocksize && + echo 16 > size && + echo 1 > memory_backed && + echo 1 > power + ) + ) && + ls -l /dev/nullb* &>>"$FULL"What's the point of these nested subshells? Can't this just be:
Quoted 11 lines
configure_null_blk() {
cd /sys/kernel/config/nullb &&
mkdir -p nullb0 &&
cd nullb0 &&
echo 0 > completion_nsec &&
echo 512 > blocksize &&
echo 16 > size &&
echo 1 > memory_backed &&
echo 1 > power &&
ls -l /dev/nullb* &>>"$FULL"
}The above code is not equivalent to the original code because it does not restore the original working directory.
When using 'cd' inside a subshell, the working directory that was effective before the 'cd' command is restored automatically when exiting from the subshell. I prefer using 'cd' in a subshell instead of using pushd / popd because with the former approach the old working directory is restored no matter how the exit from the subshell happens.
Quoted 10 lines
tests/block/029 line 39
Quoted 6 lines
tests/block/029 new file +6
-0+modify_nr_hw_queues() { + local deadline num_cpus + + deadline=$(($(_uptime_s) + TIMEOUT)) + num_cpus=$(find /sys/devices/system/cpu -maxdepth 1 -name 'cpu[0-9]*' | + wc -l)Please just use nproc. Or even better, can you just read the original value of
/sys/kernel/config/nullb/nullb0/submit_queues? Or does that start at 1?
I will have a closer look and see which alternative works best.
Bart.
Quoted 32 lines · Bart Van Assche
Quoted 19 lines · Omar Sandoval
Quoted 5 lines · Bart Van Assche
tests/block/029 new file +5
-0+# Configure one null_blk instance. +configure_null_blk() { + ( + cd /sys/kernel/config/nullb || return $? + (tests/block/029 line 31
Quoted 10 lines
tests/block/029 new file +10
-0+ mkdir -p nullb0 && + cd nullb0 && + echo 0 > completion_nsec && + echo 512 > blocksize && + echo 16 > size && + echo 1 > memory_backed && + echo 1 > power + ) + ) && + ls -l /dev/nullb* &>>"$FULL"What's the point of these nested subshells? Can't this just be:
Quoted 11 lines
configure_null_blk() { cd /sys/kernel/config/nullb && mkdir -p nullb0 && cd nullb0 && echo 0 > completion_nsec && echo 512 > blocksize && echo 16 > size && echo 1 > memory_backed && echo 1 > power && ls -l /dev/nullb* &>>"$FULL" }
Quoted 8 lines
The above code is not equivalent to the original code because it does not restore the original working directory.
When using 'cd' inside a subshell, the working directory that was effective before the 'cd' command is restored automatically when exiting from the subshell. I prefer using 'cd' in a subshell instead of using pushd / popd because with the former approach the old working directory is restored no matter how the exit from the subshell happens.
Ah, right, I didn't pay enough attention to the cd. In that case, I'd prefer not doing the cd at all. Something like:
configure_null_blk() {
local nullb0="/sys/kernel/config/nullb/nullb0"
mkdir -p "$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"
}Quoted 11 lines
Quoted 10 lines
tests/block/029 line 39
Quoted 6 lines
tests/block/029 new file +6
-0+modify_nr_hw_queues() { + local deadline num_cpus + + deadline=$(($(_uptime_s) + TIMEOUT)) + num_cpus=$(find /sys/devices/system/cpu -maxdepth 1 -name 'cpu[0-9]*' | + wc -l)Please just use nproc. Or even better, can you just read the original value of
/sys/kernel/config/nullb/nullb0/submit_queues? Or does that start at 1?
Quoted 1 line
I will have a closer look and see which alternative works best.
Thanks!