* [PATCH blktests 0/5] add new tests for blk-throttle
@ 2024-04-16 2:00 Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 1/5] tests/throtl: add first test " Yu Kuai
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 2:00 UTC (permalink / raw
To: linux-block, saranyamohan, axboe, tj; +Cc: yukuai3, yukuai1, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Yu Kuai (5):
tests/throtl: add first test for blk-throttle
tests/throtl: add a new test 002
tests/throtl: add a new test 003
tests/throtl: add a new test 004
tests/throtl: add a new test 005
tests/throtl/001 | 84 ++++++++++++++++++++++++++++++++++++++++++++
tests/throtl/001.out | 6 ++++
tests/throtl/002 | 81 ++++++++++++++++++++++++++++++++++++++++++
tests/throtl/002.out | 4 +++
tests/throtl/003 | 82 ++++++++++++++++++++++++++++++++++++++++++
tests/throtl/003.out | 4 +++
tests/throtl/004 | 79 +++++++++++++++++++++++++++++++++++++++++
tests/throtl/004.out | 4 +++
tests/throtl/005 | 83 +++++++++++++++++++++++++++++++++++++++++++
tests/throtl/005.out | 3 ++
tests/throtl/rc | 15 ++++++++
11 files changed, 445 insertions(+)
create mode 100755 tests/throtl/001
create mode 100644 tests/throtl/001.out
create mode 100755 tests/throtl/002
create mode 100644 tests/throtl/002.out
create mode 100755 tests/throtl/003
create mode 100644 tests/throtl/003.out
create mode 100755 tests/throtl/004
create mode 100644 tests/throtl/004.out
create mode 100755 tests/throtl/005
create mode 100644 tests/throtl/005.out
create mode 100644 tests/throtl/rc
--
2.39.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH blktests 1/5] tests/throtl: add first test for blk-throttle
2024-04-16 2:00 [PATCH blktests 0/5] add new tests for blk-throttle Yu Kuai
@ 2024-04-16 2:00 ` Yu Kuai
2024-04-16 3:02 ` Chaitanya Kulkarni
2024-04-16 2:00 ` [PATCH blktests 2/5] tests/throtl: add a new test 002 Yu Kuai
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 2:00 UTC (permalink / raw
To: linux-block, saranyamohan, axboe, tj; +Cc: yukuai3, yukuai1, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Test basic functionality.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
tests/throtl/001 | 84 ++++++++++++++++++++++++++++++++++++++++++++
tests/throtl/001.out | 6 ++++
tests/throtl/rc | 15 ++++++++
3 files changed, 105 insertions(+)
create mode 100755 tests/throtl/001
create mode 100644 tests/throtl/001.out
create mode 100644 tests/throtl/rc
diff --git a/tests/throtl/001 b/tests/throtl/001
new file mode 100755
index 0000000..79ecf07
--- /dev/null
+++ b/tests/throtl/001
@@ -0,0 +1,84 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Yu Kuai
+#
+# Test basic functionality of blk-throttle
+
+. tests/throtl/rc
+
+DESCRIPTION="basic functionality"
+QUICK=1
+
+CG=/sys/fs/cgroup
+TEST_DIR=$CG/blktests_throtl
+devname=nullb0
+dev=""
+
+set_up_test() {
+ if ! _init_null_blk nr_devices=1; then
+ return 1;
+ fi
+
+ dev=$(cat /sys/block/$devname/dev)
+ echo +io > $CG/cgroup.subtree_control
+ mkdir $TEST_DIR
+
+ return 0;
+}
+
+clean_up_test() {
+ rmdir $TEST_DIR
+ echo -io > $CG/cgroup.subtree_control
+ _exit_null_blk
+}
+
+config_throtl() {
+ echo "$dev $*" > $TEST_DIR/io.max
+}
+
+remove_config() {
+ echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
+}
+
+test_io() {
+ config_throtl "$1"
+
+ {
+ sleep 0.1
+ start_time=$(date +%s.%N)
+
+ if [ "$2" == "read" ]; then
+ dd if=/dev/$devname of=/dev/null bs=4k count=256 iflag=direct status=none
+ elif [ "$2" == "write" ]; then
+ dd of=/dev/$devname if=/dev/zero bs=4k count=256 oflag=direct status=none
+ fi
+
+ end_time=$(date +%s.%N)
+ elapsed=$(echo "$end_time - $start_time" | bc)
+ printf "%.0f\n" "$elapsed"
+ } &
+
+ pid=$!
+ echo $! > $TEST_DIR/cgroup.procs
+ wait $pid
+
+ remove_config
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ if ! set_up_test; then
+ return 1;
+ fi
+
+ _1MB=$((1024 * 1024))
+
+ test_io wbps=$_1MB write
+ test_io wiops=256 write
+ test_io rbps=$_1MB read
+ test_io riops=256 read
+
+ clean_up_test
+ echo "Test complete"
+}
diff --git a/tests/throtl/001.out b/tests/throtl/001.out
new file mode 100644
index 0000000..a3edfdd
--- /dev/null
+++ b/tests/throtl/001.out
@@ -0,0 +1,6 @@
+Running throtl/001
+1
+1
+1
+1
+Test complete
diff --git a/tests/throtl/rc b/tests/throtl/rc
new file mode 100644
index 0000000..8fa8b58
--- /dev/null
+++ b/tests/throtl/rc
@@ -0,0 +1,15 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Yu Kuai
+#
+# Tests for blk-throttle
+
+. common/rc
+. common/null_blk
+
+group_requires() {
+ _have_root
+ _have_null_blk
+ _have_kernel_option BLK_DEV_THROTTLING
+ _have_cgroup2_controller io
+}
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH blktests 2/5] tests/throtl: add a new test 002
2024-04-16 2:00 [PATCH blktests 0/5] add new tests for blk-throttle Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 1/5] tests/throtl: add first test " Yu Kuai
@ 2024-04-16 2:00 ` Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 3/5] tests/throtl: add a new test 003 Yu Kuai
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 2:00 UTC (permalink / raw
To: linux-block, saranyamohan, axboe, tj; +Cc: yukuai3, yukuai1, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Test iops limit over IO split, regression tests for:
commit 9f5ede3c01f9 ("block: throttle split bio in case of iops limit")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
tests/throtl/002 | 81 ++++++++++++++++++++++++++++++++++++++++++++
tests/throtl/002.out | 4 +++
2 files changed, 85 insertions(+)
create mode 100755 tests/throtl/002
create mode 100644 tests/throtl/002.out
diff --git a/tests/throtl/002 b/tests/throtl/002
new file mode 100755
index 0000000..e0df4b8
--- /dev/null
+++ b/tests/throtl/002
@@ -0,0 +1,81 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Yu Kuai
+#
+# Test iops limit work correctly for big IO of blk-throttle, regression test
+# for commit 9f5ede3c01f9 ("block: throttle split bio in case of iops limit")
+
+. tests/throtl/rc
+
+DESCRIPTION="iops limit over IO split"
+QUICK=1
+
+CG=/sys/fs/cgroup
+TEST_DIR=$CG/blktests_throtl
+devname=nullb0
+dev=""
+
+set_up_test() {
+ if ! _init_null_blk max_sectors=8; then
+ return 1;
+ fi
+
+ dev=$(cat /sys/block/$devname/dev)
+ echo +io > $CG/cgroup.subtree_control
+ mkdir $TEST_DIR
+
+ return 0;
+}
+
+clean_up_test() {
+ rmdir $TEST_DIR
+ echo -io > $CG/cgroup.subtree_control
+ _exit_null_blk
+}
+
+config_throtl() {
+ echo "$dev $*" > $TEST_DIR/io.max
+}
+
+remove_config() {
+ echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
+}
+
+test_io() {
+ config_throtl "$1"
+
+ {
+ sleep 0.1
+ start_time=$(date +%s.%N)
+
+ if [ "$2" == "read" ]; then
+ dd if=/dev/$devname of=/dev/null bs=1M count=1 iflag=direct status=none
+ elif [ "$2" == "write" ]; then
+ dd of=/dev/$devname if=/dev/zero bs=1M count=1 oflag=direct status=none
+ fi
+
+ end_time=$(date +%s.%N)
+ elapsed=$(echo "$end_time - $start_time" | bc)
+ printf "%.0f\n" "$elapsed"
+ } &
+
+ pid=$!
+ echo $! > $TEST_DIR/cgroup.procs
+ wait $pid
+
+ remove_config
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ if ! set_up_test; then
+ return 1;
+ fi
+
+ test_io wiops=256 write
+ test_io riops=256 read
+
+ clean_up_test
+ echo "Test complete"
+}
diff --git a/tests/throtl/002.out b/tests/throtl/002.out
new file mode 100644
index 0000000..7e1ae85
--- /dev/null
+++ b/tests/throtl/002.out
@@ -0,0 +1,4 @@
+Running throtl/002
+1
+1
+Test complete
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH blktests 3/5] tests/throtl: add a new test 003
2024-04-16 2:00 [PATCH blktests 0/5] add new tests for blk-throttle Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 1/5] tests/throtl: add first test " Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 2/5] tests/throtl: add a new test 002 Yu Kuai
@ 2024-04-16 2:00 ` Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 4/5] tests/throtl: add a new test 004 Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 5/5] tests/throtl: add a new test 005 Yu Kuai
4 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 2:00 UTC (permalink / raw
To: linux-block, saranyamohan, axboe, tj; +Cc: yukuai3, yukuai1, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Test bps limit over IO split, regression tests for:
commit 111be8839817 ("block-throttle: avoid double charge")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
tests/throtl/003 | 82 ++++++++++++++++++++++++++++++++++++++++++++
tests/throtl/003.out | 4 +++
2 files changed, 86 insertions(+)
create mode 100755 tests/throtl/003
create mode 100644 tests/throtl/003.out
diff --git a/tests/throtl/003 b/tests/throtl/003
new file mode 100755
index 0000000..06d594c
--- /dev/null
+++ b/tests/throtl/003
@@ -0,0 +1,82 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Yu Kuai
+#
+# Test bps limit work correctly for big IO of blk-throttle, regression test for
+# commie 111be8839817 ("block-throttle: avoid double charge")
+
+. tests/throtl/rc
+
+DESCRIPTION="bps limit over IO split"
+QUICK=1
+
+CG=/sys/fs/cgroup
+TEST_DIR=$CG/blktests_throtl
+devname=nullb0
+dev=""
+
+set_up_test() {
+ if ! _init_null_blk max_sectors=8; then
+ return 1;
+ fi
+
+ dev=$(cat /sys/block/$devname/dev)
+ echo +io > $CG/cgroup.subtree_control
+ mkdir $TEST_DIR
+
+ return 0;
+}
+
+clean_up_test() {
+ rmdir $TEST_DIR
+ echo -io > $CG/cgroup.subtree_control
+ _exit_null_blk
+}
+
+config_throtl() {
+ echo "$dev $*" > $TEST_DIR/io.max
+}
+
+remove_config() {
+ echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
+}
+
+test_io() {
+ config_throtl "$1"
+
+ {
+ sleep 0.1
+ start_time=$(date +%s.%N)
+
+ if [ "$2" == "read" ]; then
+ dd if=/dev/$devname of=/dev/null bs=1M count=1 iflag=direct status=none
+ elif [ "$2" == "write" ]; then
+ dd of=/dev/$devname if=/dev/zero bs=1M count=1 oflag=direct status=none
+ fi
+
+ end_time=$(date +%s.%N)
+ elapsed=$(echo "$end_time - $start_time" | bc)
+ printf "%.0f\n" "$elapsed"
+ } &
+
+ pid=$!
+ echo $! > $TEST_DIR/cgroup.procs
+ wait $pid
+
+ remove_config
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ if ! set_up_test; then
+ return 1;
+ fi
+
+ limit=$((1024 * 1024))
+ test_io wbps=$limit write
+ test_io rbps=$limit read
+
+ clean_up_test
+ echo "Test complete"
+}
diff --git a/tests/throtl/003.out b/tests/throtl/003.out
new file mode 100644
index 0000000..07a80b3
--- /dev/null
+++ b/tests/throtl/003.out
@@ -0,0 +1,4 @@
+Running throtl/003
+1
+1
+Test complete
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH blktests 4/5] tests/throtl: add a new test 004
2024-04-16 2:00 [PATCH blktests 0/5] add new tests for blk-throttle Yu Kuai
` (2 preceding siblings ...)
2024-04-16 2:00 ` [PATCH blktests 3/5] tests/throtl: add a new test 003 Yu Kuai
@ 2024-04-16 2:00 ` Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 5/5] tests/throtl: add a new test 005 Yu Kuai
4 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 2:00 UTC (permalink / raw
To: linux-block, saranyamohan, axboe, tj; +Cc: yukuai3, yukuai1, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Test delete the disk while IO is throttled, regerssion test for:
commit 884f0e84f1e3 ("blk-throttle: fix UAF by deleteing timer in blk_throtl_exit()")
commit 8f9e7b65f833 ("block: cancel all throttled bios in del_gendisk()")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
tests/throtl/004 | 79 ++++++++++++++++++++++++++++++++++++++++++++
tests/throtl/004.out | 4 +++
2 files changed, 83 insertions(+)
create mode 100755 tests/throtl/004
create mode 100644 tests/throtl/004.out
diff --git a/tests/throtl/004 b/tests/throtl/004
new file mode 100755
index 0000000..d07f9d5
--- /dev/null
+++ b/tests/throtl/004
@@ -0,0 +1,79 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Yu Kuai
+#
+# Test delete the disk while IO is throttled, regerssion test for
+# commit 884f0e84f1e3 ("blk-throttle: fix UAF by deleteing timer in blk_throtl_exit()")
+# commit 8f9e7b65f833 ("block: cancel all throttled bios in del_gendisk()")
+
+. tests/throtl/rc
+
+DESCRIPTION="delete disk while IO is throttled"
+QUICK=1
+
+CG=/sys/fs/cgroup
+TEST_DIR=$CG/blktests_throtl
+devname=nullb0
+dev=""
+
+set_up_test() {
+ if ! _init_null_blk nr_devices=0; then
+ return 1;
+ fi
+
+ if ! _configure_null_blk $devname power=1; then
+ return 1;
+ fi
+
+ dev=$(cat /sys/block/$devname/dev)
+ echo +io > $CG/cgroup.subtree_control
+ mkdir $TEST_DIR
+
+ return 0;
+}
+
+clean_up_test() {
+ rmdir $TEST_DIR
+ echo -io > $CG/cgroup.subtree_control
+ _exit_null_blk
+}
+
+config_throtl() {
+ limit=$((1024 * 1024))
+ echo "$dev wbps=$limit" > $TEST_DIR/io.max
+}
+
+test_io() {
+ config_throtl
+
+ {
+ sleep 0.1
+ start_time=$(date +%s.%N)
+
+ dd of=/dev/$devname if=/dev/zero bs=10M count=1 oflag=direct status=none
+
+ end_time=$(date +%s.%N)
+ elapsed=$(echo "$end_time - $start_time" | bc)
+ printf "%.0f\n" "$elapsed"
+ } &
+
+ pid=$!
+ echo $! > $TEST_DIR/cgroup.procs
+
+ sleep 1
+ echo 0 > /sys/kernel/config/nullb/$devname/power
+ wait $pid
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ if ! set_up_test; then
+ return 1;
+ fi
+
+ test_io
+
+ clean_up_test
+ echo "Test complete"
+}
diff --git a/tests/throtl/004.out b/tests/throtl/004.out
new file mode 100644
index 0000000..03331fe
--- /dev/null
+++ b/tests/throtl/004.out
@@ -0,0 +1,4 @@
+Running throtl/004
+dd: error writing '/dev/nullb0': Input/output error
+1
+Test complete
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH blktests 5/5] tests/throtl: add a new test 005
2024-04-16 2:00 [PATCH blktests 0/5] add new tests for blk-throttle Yu Kuai
` (3 preceding siblings ...)
2024-04-16 2:00 ` [PATCH blktests 4/5] tests/throtl: add a new test 004 Yu Kuai
@ 2024-04-16 2:00 ` Yu Kuai
4 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 2:00 UTC (permalink / raw
To: linux-block, saranyamohan, axboe, tj; +Cc: yukuai3, yukuai1, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Test change config while IO is throttled, regression test for:
commit a880ae93e5b5 ("blk-throttle: fix io hung due to configuration updates")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
tests/throtl/005 | 83 ++++++++++++++++++++++++++++++++++++++++++++
tests/throtl/005.out | 3 ++
2 files changed, 86 insertions(+)
create mode 100755 tests/throtl/005
create mode 100644 tests/throtl/005.out
diff --git a/tests/throtl/005 b/tests/throtl/005
new file mode 100755
index 0000000..6caac99
--- /dev/null
+++ b/tests/throtl/005
@@ -0,0 +1,83 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Yu Kuai
+#
+# Test change config while IO is throttled, regression test for
+# commit a880ae93e5b5 ("blk-throttle: fix io hung due to configuration updates")
+
+. tests/throtl/rc
+
+DESCRIPTION="change config with throttled IO"
+QUICK=1
+
+CG=/sys/fs/cgroup
+TEST_DIR=$CG/blktests_throtl
+devname=nullb0
+dev=""
+
+set_up_test() {
+ if ! _init_null_blk max_sectors=8; then
+ return 1;
+ fi
+
+ dev=$(cat /sys/block/$devname/dev)
+ echo +io > $CG/cgroup.subtree_control
+ mkdir $TEST_DIR
+
+ return 0;
+}
+
+clean_up_test() {
+ rmdir $TEST_DIR
+ echo -io > $CG/cgroup.subtree_control
+ _exit_null_blk
+}
+
+config_throtl() {
+ echo "$dev $*" > $TEST_DIR/io.max
+}
+
+remove_config() {
+ echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
+}
+
+test_io() {
+ limit=$((512 * 1024))
+ config_throtl wbps=$limit
+
+ {
+ sleep 0.1
+ start_time=$(date +%s.%N)
+
+ dd of=/dev/$devname if=/dev/zero bs=1M count=1 oflag=direct status=none
+
+ # old limit is 512k, issue 1M IO, swith to new limit 215k after 1s
+ # expected wait time is 3s
+ end_time=$(date +%s.%N)
+ elapsed=$(echo "$end_time - $start_time" | bc)
+ printf "%.0f\n" "$elapsed"
+ } &
+
+ pid=$!
+ echo $! > $TEST_DIR/cgroup.procs
+
+ sleep 1
+ limit=$((256 * 1024))
+ config_throtl wbps=$limit
+ wait $pid
+
+ remove_config
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ if ! set_up_test; then
+ return 1;
+ fi
+
+ test_io
+
+ clean_up_test
+ echo "Test complete"
+}
diff --git a/tests/throtl/005.out b/tests/throtl/005.out
new file mode 100644
index 0000000..1d23210
--- /dev/null
+++ b/tests/throtl/005.out
@@ -0,0 +1,3 @@
+Running throtl/005
+3
+Test complete
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH blktests 1/5] tests/throtl: add first test for blk-throttle
2024-04-16 2:00 ` [PATCH blktests 1/5] tests/throtl: add first test " Yu Kuai
@ 2024-04-16 3:02 ` Chaitanya Kulkarni
2024-04-16 3:17 ` Yu Kuai
0 siblings, 1 reply; 9+ messages in thread
From: Chaitanya Kulkarni @ 2024-04-16 3:02 UTC (permalink / raw
To: Yu Kuai
Cc: yukuai3@huawei.com, yangerkun@huawei.com, tj@kernel.org,
saranyamohan@google.com, linux-block@vger.kernel.org,
axboe@kernel.dk
On 4/15/24 19:00, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Test basic functionality.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> tests/throtl/001 | 84 ++++++++++++++++++++++++++++++++++++++++++++
> tests/throtl/001.out | 6 ++++
> tests/throtl/rc | 15 ++++++++
> 3 files changed, 105 insertions(+)
> create mode 100755 tests/throtl/001
> create mode 100644 tests/throtl/001.out
> create mode 100644 tests/throtl/rc
>
> diff --git a/tests/throtl/001 b/tests/throtl/001
> new file mode 100755
> index 0000000..79ecf07
> --- /dev/null
> +++ b/tests/throtl/001
> @@ -0,0 +1,84 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2024 Yu Kuai
> +#
> +# Test basic functionality of blk-throttle
> +
> +. tests/throtl/rc
> +
> +DESCRIPTION="basic functionality"
> +QUICK=1
> +
> +CG=/sys/fs/cgroup
> +TEST_DIR=$CG/blktests_throtl
> +devname=nullb0
> +dev=""
> +
> +set_up_test() {
> + if ! _init_null_blk nr_devices=1; then
> + return 1;
> + fi
> +
> + dev=$(cat /sys/block/$devname/dev)
> + echo +io > $CG/cgroup.subtree_control
> + mkdir $TEST_DIR
> +
move above to 3 lines to rc with helper instead of repeating the
code for every test ?
> + return 0;
> +}
> +
> +clean_up_test() {
> + rmdir $TEST_DIR
> + echo -io > $CG/cgroup.subtree_control
> + _exit_null_blk
same here ?
> +}
> +
> +config_throtl() {
> + echo "$dev $*" > $TEST_DIR/io.max
> +}
> +
> +remove_config() {
> + echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
> +}
> +
same here for above two helper ?
> +test_io() {
> + config_throtl "$1"
> +
> + {
> + sleep 0.1
> + start_time=$(date +%s.%N)
> +
> + if [ "$2" == "read" ]; then
> + dd if=/dev/$devname of=/dev/null bs=4k count=256 iflag=direct status=none
> + elif [ "$2" == "write" ]; then
> + dd of=/dev/$devname if=/dev/zero bs=4k count=256 oflag=direct status=none
> + fi
Is there a any specific reason to use dd and not fio ?
> +
> + end_time=$(date +%s.%N)
> + elapsed=$(echo "$end_time - $start_time" | bc)
> + printf "%.0f\n" "$elapsed"
> + } &
> +
> + pid=$!
> + echo $! > $TEST_DIR/cgroup.procs
> + wait $pid
> +
> + remove_config
> +}
> +
apparently test_io is also repeated can be moved to rc with right
parameters ?
> +test() {
> + echo "Running ${TEST_NAME}"
> +
> + if ! set_up_test; then
> + return 1;
> + fi
> +
> + _1MB=$((1024 * 1024))
starting variable name with _ seems a but weired, why not just pass
$((1024 *1024)) ?
> +
> + test_io wbps=$_1MB write
> + test_io wiops=256 write
> + test_io rbps=$_1MB read
> + test_io riops=256 read
> +
> + clean_up_test
> + echo "Test complete"
> +}
> diff --git a/tests/throtl/001.out b/tests/throtl/001.out
> new file mode 100644
> index 0000000..a3edfdd
> --- /dev/null
> +++ b/tests/throtl/001.out
> @@ -0,0 +1,6 @@
> +Running throtl/001
> +1
> +1
> +1
> +1
> +Test complete
> diff --git a/tests/throtl/rc b/tests/throtl/rc
> new file mode 100644
> index 0000000..8fa8b58
> --- /dev/null
> +++ b/tests/throtl/rc
> @@ -0,0 +1,15 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2024 Yu Kuai
> +#
> +# Tests for blk-throttle
> +
> +. common/rc
> +. common/null_blk
> +
> +group_requires() {
> + _have_root
> + _have_null_blk
> + _have_kernel_option BLK_DEV_THROTTLING
> + _have_cgroup2_controller io
> +}
apart from that thanks for the tests ..
-ck
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH blktests 1/5] tests/throtl: add first test for blk-throttle
2024-04-16 3:02 ` Chaitanya Kulkarni
@ 2024-04-16 3:17 ` Yu Kuai
2024-04-16 3:37 ` Chaitanya Kulkarni
0 siblings, 1 reply; 9+ messages in thread
From: Yu Kuai @ 2024-04-16 3:17 UTC (permalink / raw
To: Chaitanya Kulkarni, Yu Kuai
Cc: yangerkun@huawei.com, tj@kernel.org, saranyamohan@google.com,
linux-block@vger.kernel.org, axboe@kernel.dk, yukuai (C)
Hi,
在 2024/04/16 11:02, Chaitanya Kulkarni 写道:
> On 4/15/24 19:00, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Test basic functionality.
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>> tests/throtl/001 | 84 ++++++++++++++++++++++++++++++++++++++++++++
>> tests/throtl/001.out | 6 ++++
>> tests/throtl/rc | 15 ++++++++
>> 3 files changed, 105 insertions(+)
>> create mode 100755 tests/throtl/001
>> create mode 100644 tests/throtl/001.out
>> create mode 100644 tests/throtl/rc
>>
>> diff --git a/tests/throtl/001 b/tests/throtl/001
>> new file mode 100755
>> index 0000000..79ecf07
>> --- /dev/null
>> +++ b/tests/throtl/001
>> @@ -0,0 +1,84 @@
>> +#!/bin/bash
>> +# SPDX-License-Identifier: GPL-3.0+
>> +# Copyright (C) 2024 Yu Kuai
>> +#
>> +# Test basic functionality of blk-throttle
>> +
>> +. tests/throtl/rc
>> +
>> +DESCRIPTION="basic functionality"
>> +QUICK=1
>> +
>> +CG=/sys/fs/cgroup
>> +TEST_DIR=$CG/blktests_throtl
>> +devname=nullb0
>> +dev=""
>> +
>> +set_up_test() {
>> + if ! _init_null_blk nr_devices=1; then
>> + return 1;
>> + fi
>> +
>> + dev=$(cat /sys/block/$devname/dev)
>> + echo +io > $CG/cgroup.subtree_control
>> + mkdir $TEST_DIR
>> +
>
> move above to 3 lines to rc with helper instead of repeating the
> code for every test ?
Yes, that sounds good, just test 004 is different.
>
>> + return 0;
>> +}
>> +
>> +clean_up_test() {
>> + rmdir $TEST_DIR
>> + echo -io > $CG/cgroup.subtree_control
>> + _exit_null_blk
>
> same here ?
>
>> +}
>> +
>> +config_throtl() {
>> + echo "$dev $*" > $TEST_DIR/io.max
>> +}
>> +
>> +remove_config() {
>> + echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
>> +}
>> +
>
> same here for above two helper ?
Yes, of course.
>
>> +test_io() {
>> + config_throtl "$1"
>> +
>> + {
>> + sleep 0.1
>> + start_time=$(date +%s.%N)
>> +
>> + if [ "$2" == "read" ]; then
>> + dd if=/dev/$devname of=/dev/null bs=4k count=256 iflag=direct status=none
>> + elif [ "$2" == "write" ]; then
>> + dd of=/dev/$devname if=/dev/zero bs=4k count=256 oflag=direct status=none
>> + fi
>
> Is there a any specific reason to use dd and not fio ?
My thoughts is that I need to make sure the number and the size
of IO that I dispatched, so that I can predict the throttle time,
and we don't need to keep issuing new IO based on time here.
>
>> +
>> + end_time=$(date +%s.%N)
>> + elapsed=$(echo "$end_time - $start_time" | bc)
>> + printf "%.0f\n" "$elapsed"
>> + } &
>> +
>> + pid=$!
>> + echo $! > $TEST_DIR/cgroup.procs
>> + wait $pid
>> +
>> + remove_config
>> +}
>> +
>
> apparently test_io is also repeated can be moved to rc with right
> parameters ?
There is slight difference, however, the answer is apparently yes.
>
>> +test() {
>> + echo "Running ${TEST_NAME}"
>> +
>> + if ! set_up_test; then
>> + return 1;
>> + fi
>> +
>> + _1MB=$((1024 * 1024))
>
> starting variable name with _ seems a but weired, why not just pass
> $((1024 *1024)) ?
I'll use the name $bps_limit here, just think to prevent the same code
is better...
Thanks,
Kuai
>
>> +
>> + test_io wbps=$_1MB write
>> + test_io wiops=256 write
>> + test_io rbps=$_1MB read
>> + test_io riops=256 read
>> +
>> + clean_up_test
>> + echo "Test complete"
>> +}
>> diff --git a/tests/throtl/001.out b/tests/throtl/001.out
>> new file mode 100644
>> index 0000000..a3edfdd
>> --- /dev/null
>> +++ b/tests/throtl/001.out
>> @@ -0,0 +1,6 @@
>> +Running throtl/001
>> +1
>> +1
>> +1
>> +1
>> +Test complete
>> diff --git a/tests/throtl/rc b/tests/throtl/rc
>> new file mode 100644
>> index 0000000..8fa8b58
>> --- /dev/null
>> +++ b/tests/throtl/rc
>> @@ -0,0 +1,15 @@
>> +#!/bin/bash
>> +# SPDX-License-Identifier: GPL-3.0+
>> +# Copyright (C) 2024 Yu Kuai
>> +#
>> +# Tests for blk-throttle
>> +
>> +. common/rc
>> +. common/null_blk
>> +
>> +group_requires() {
>> + _have_root
>> + _have_null_blk
>> + _have_kernel_option BLK_DEV_THROTTLING
>> + _have_cgroup2_controller io
>> +}
>
> apart from that thanks for the tests ..
>
> -ck
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH blktests 1/5] tests/throtl: add first test for blk-throttle
2024-04-16 3:17 ` Yu Kuai
@ 2024-04-16 3:37 ` Chaitanya Kulkarni
0 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2024-04-16 3:37 UTC (permalink / raw
To: Yu Kuai
Cc: yangerkun@huawei.com, tj@kernel.org, saranyamohan@google.com,
linux-block@vger.kernel.org, axboe@kernel.dk, yukuai (C)
On 4/15/24 20:17, Yu Kuai wrote:
> Hi,
>
> 在 2024/04/16 11:02, Chaitanya Kulkarni 写道:
>> On 4/15/24 19:00, Yu Kuai wrote:
>>> From: Yu Kuai <yukuai3@huawei.com>
>>>
>>> Test basic functionality.
>>>
>>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>>> ---
>>> tests/throtl/001 | 84
>>> ++++++++++++++++++++++++++++++++++++++++++++
>>> tests/throtl/001.out | 6 ++++
>>> tests/throtl/rc | 15 ++++++++
>>> 3 files changed, 105 insertions(+)
>>> create mode 100755 tests/throtl/001
>>> create mode 100644 tests/throtl/001.out
>>> create mode 100644 tests/throtl/rc
>>>
>>> diff --git a/tests/throtl/001 b/tests/throtl/001
>>> new file mode 100755
>>> index 0000000..79ecf07
>>> --- /dev/null
>>> +++ b/tests/throtl/001
>>> @@ -0,0 +1,84 @@
>>> +#!/bin/bash
>>> +# SPDX-License-Identifier: GPL-3.0+
>>> +# Copyright (C) 2024 Yu Kuai
>>> +#
>>> +# Test basic functionality of blk-throttle
>>> +
>>> +. tests/throtl/rc
>>> +
>>> +DESCRIPTION="basic functionality"
>>> +QUICK=1
>>> +
>>> +CG=/sys/fs/cgroup
>>> +TEST_DIR=$CG/blktests_throtl
>>> +devname=nullb0
>>> +dev=""
>>> +
>>> +set_up_test() {
>>> + if ! _init_null_blk nr_devices=1; then
>>> + return 1;
>>> + fi
>>> +
>>> + dev=$(cat /sys/block/$devname/dev)
>>> + echo +io > $CG/cgroup.subtree_control
>>> + mkdir $TEST_DIR
>>> +
>>
>> move above to 3 lines to rc with helper instead of repeating the
>> code for every test ?
>
> Yes, that sounds good, just test 004 is different.
indeed, but for future tests we are going need that anyways ..
>>
>>> + return 0;
>>> +}
>>> +
>>> +clean_up_test() {
>>> + rmdir $TEST_DIR
>>> + echo -io > $CG/cgroup.subtree_control
>>> + _exit_null_blk
>>
>> same here ?
>>
>>> +}
>>> +
>>> +config_throtl() {
>>> + echo "$dev $*" > $TEST_DIR/io.max
>>> +}
>>> +
>>> +remove_config() {
>>> + echo "$dev rbps=max wbps=max riops=max wiops=max" >
>>> $TEST_DIR/io.max
>>> +}
>>> +
>>
>> same here for above two helper ?
>
> Yes, of course.
>>
>>> +test_io() {
>>> + config_throtl "$1"
>>> +
>>> + {
>>> + sleep 0.1
>>> + start_time=$(date +%s.%N)
>>> +
>>> + if [ "$2" == "read" ]; then
>>> + dd if=/dev/$devname of=/dev/null bs=4k count=256
>>> iflag=direct status=none
>>> + elif [ "$2" == "write" ]; then
>>> + dd of=/dev/$devname if=/dev/zero bs=4k count=256
>>> oflag=direct status=none
>>> + fi
>>
>> Is there a any specific reason to use dd and not fio ?
>
> My thoughts is that I need to make sure the number and the size
> of IO that I dispatched, so that I can predict the throttle time,
> and we don't need to keep issuing new IO based on time here.
I believe we can do that with fio too, no ? the reason I'm asking
with fio we can specify io_engine and I believe we shuold
be using io_uring in general ? but then for such small I/Os it
may not matter so we can keep it as is ... I'll leave it to you ..
-ck
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-04-16 3:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16 2:00 [PATCH blktests 0/5] add new tests for blk-throttle Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 1/5] tests/throtl: add first test " Yu Kuai
2024-04-16 3:02 ` Chaitanya Kulkarni
2024-04-16 3:17 ` Yu Kuai
2024-04-16 3:37 ` Chaitanya Kulkarni
2024-04-16 2:00 ` [PATCH blktests 2/5] tests/throtl: add a new test 002 Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 3/5] tests/throtl: add a new test 003 Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 4/5] tests/throtl: add a new test 004 Yu Kuai
2024-04-16 2:00 ` [PATCH blktests 5/5] tests/throtl: add a new test 005 Yu Kuai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).