From patchwork Tue Apr 16 02:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13631083 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08F09101D4 for ; Tue, 16 Apr 2024 02:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233379; cv=none; b=ncKEz6rhKnY645zj7uKc210Ljkpo/UG0x/wJN/zm60Y5VEk52OcwAcoWF6af4tpjcLexRY6Nw/c/y6M4+MAJqortT/okRKOr966jf0YX9dG1mSN6e0SMyLhqAyziZ1twGTyjN3NIrp204ZWjWrwz940ze/sR7P2TzW0GRzdM1Sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233379; c=relaxed/simple; bh=QY2UmapfjHqKpWTR86/iwDu8gIFov+9M/HigXIwD8c8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jYuP0EQfcWFJ7RGINDtvc4M4XSGV4OAYZ4Jdss1zWTEKC/BvvNXTS87ORywgLYupDrTMWUSoySJsCeOerEXyJ7bLChXXgNLwT+tmdvkDh12MxxAsEKZwL9HZyPWzsgHI1vWkgyXz8gjotSHtxCBBBsJxreu2iv1uNGCkcYHUQ6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VJSCL14nYz4f3nV5 for ; Tue, 16 Apr 2024 10:09:18 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 085AD1A0179 for ; Tue, 16 Apr 2024 10:09:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g7U3R1mMNVnKA--.11112S5; Tue, 16 Apr 2024 10:09:26 +0800 (CST) From: Yu Kuai To: linux-block@vger.kernel.org, saranyamohan@google.com, axboe@kernel.dk, tj@kernel.org Cc: yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH blktests 1/5] tests/throtl: add first test for blk-throttle Date: Tue, 16 Apr 2024 10:00:38 +0800 Message-Id: <20240416020042.509291-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416020042.509291-1-yukuai1@huaweicloud.com> References: <20240416020042.509291-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g7U3R1mMNVnKA--.11112S5 X-Coremail-Antispam: 1UD129KBjvJXoWxWF4fJr1fAw48Gr4UXr1xAFb_yoW5XFy8pa yUWa1Fkr4xGFnrtFy3K3WUWayrZws3AF47A347Wr15Ar42q3yUtF12kw1UtrWrJFZFgFWr Za18XF4FkF18ZFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUqAp5UUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Test basic functionality. Signed-off-by: Yu Kuai --- 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 +} From patchwork Tue Apr 16 02:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13631080 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94899107A6 for ; Tue, 16 Apr 2024 02:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233378; cv=none; b=LlLGa/ZY/2Ytat3KzOlsYjuCv/qFkLPyjYljX8zkvdJtzq6ybM76zDFlewDDqvDoGCIqnK32tXKAv0c4gn2uRREfE0UFiBHrhUloH8zSbbEKpwhPXtzjX3BJ3Al7ujfxo2DiAReE4J6MWz1l8gW9J+Yny7bosK2WMJgqv0CZiU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233378; c=relaxed/simple; bh=ZCcOZ0EfdxN6M+eQ+PeubeyX5Yxm8vec6Pj6kVsb1bs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xoe6pW0Q1fb9Ql5j7K3fGPM1297z8+rkL15u481TcajYSuksTx+jI7wiQHVuFg4JnlY/QK4dNP1KsZXq5M59+1sKHQXTzI4p7MXWM/flLxV/mIcvyiXZE4HhmNq2aK1uBmbwcAMO/ayAIQvTNCZ0k22GWvgLuIjGWwLJI2vaflU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VJSCQ5LXbz4f3lX6 for ; Tue, 16 Apr 2024 10:09:22 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 55FC51A016E for ; Tue, 16 Apr 2024 10:09:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g7U3R1mMNVnKA--.11112S6; Tue, 16 Apr 2024 10:09:27 +0800 (CST) From: Yu Kuai To: linux-block@vger.kernel.org, saranyamohan@google.com, axboe@kernel.dk, tj@kernel.org Cc: yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH blktests 2/5] tests/throtl: add a new test 002 Date: Tue, 16 Apr 2024 10:00:39 +0800 Message-Id: <20240416020042.509291-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416020042.509291-1-yukuai1@huaweicloud.com> References: <20240416020042.509291-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g7U3R1mMNVnKA--.11112S6 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw4DZw47Gw4kCr15Cw4kZwb_yoW8KF1xpF WUGF4rKF48WFnrtFy3t3Wj9ayrZws5ArW7A343Xr1FvFnFv3y7KF1Iyr1IyFWfGr9rWr1r Za1vqFZ5K3WUX37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUc6pPUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai 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 --- 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 From patchwork Tue Apr 16 02:00:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13631081 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9335610795 for ; Tue, 16 Apr 2024 02:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233378; cv=none; b=PTTdo6t33uKHVzmEM88zIcBaUnoMJ2aplQ7j0mnANuH6RIQ87IoqQd3WSniT+qYg+qWgYivmaVoudB6CtNpU4lsm9yntbWkld+HYqi8UfPL05bhub54EnxaKmc6dupZWuHrIopgUianwSeDYXMdlJHiGQqB9YPgA0x8Xw9RKJ1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233378; c=relaxed/simple; bh=U/Ts3RsjXBLCxYX5pJ55/h68DXKerA0R7i5vP9qR34s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U8b2j+rAXKyBPOi11pEIepCiyHYlcsy+HHqrAChPDIi97sfcWgpClF1Uu8LoOW6XBvLm/onFxMVYpd/bIKgzyUe0BmRfgXETWpFYIkd+LeTLbDe2Z3TUYfFMMnUFkbYu7vWiEpDTctJyUgbo5xjxodSVhxyZSl1ojlZ1uoDIF3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VJSCR0bLrz4f3lXF for ; Tue, 16 Apr 2024 10:09:23 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id A8FE71A0568 for ; Tue, 16 Apr 2024 10:09:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g7U3R1mMNVnKA--.11112S7; Tue, 16 Apr 2024 10:09:27 +0800 (CST) From: Yu Kuai To: linux-block@vger.kernel.org, saranyamohan@google.com, axboe@kernel.dk, tj@kernel.org Cc: yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH blktests 3/5] tests/throtl: add a new test 003 Date: Tue, 16 Apr 2024 10:00:40 +0800 Message-Id: <20240416020042.509291-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416020042.509291-1-yukuai1@huaweicloud.com> References: <20240416020042.509291-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g7U3R1mMNVnKA--.11112S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr4DJFW3CFyxCF1kury8Zrb_yoW8KF4rpr WUCayrtr4xCFnrtrZxt3WqgayfZws5ArW7A3srJr1rXFy2q3yUWr1Iyr15tFZ3GrnFgr1r Za18XrZ5KF17XrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUd8n5UUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Test bps limit over IO split, regression tests for: commit 111be8839817 ("block-throttle: avoid double charge") Signed-off-by: Yu Kuai --- 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 From patchwork Tue Apr 16 02:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13631084 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F754101E2 for ; Tue, 16 Apr 2024 02:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233379; cv=none; b=mtJYAeCKd6iuka+FBTBAm/1Z/Ww0BfS1X4NM3glkR0ZOivKciAW4stkcYYZnZXO2nLUXNXaygOYeDkEGtMcLmKlECWmRI5llwNFj4kC9o8aTvu9/s/yp5OQAGJ36Q7hJWJnfVmtVpB7x+oFZZGLiEmtlXx5Mndjqw2a0AXf3m2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233379; c=relaxed/simple; bh=5R5XIlFRSueQFPENVDXwCkXhhyDD4OCbFLx1d1JaQe0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SDxZz4q+fGXT+220DXCngrdpB46TJpG7H9Ev9QBsqPZA+sRzoVvkLq6w66HKGsh5dkNW7G0IIFOFGQP0v+ozf+tRexLU7K51P88qmtfqfHuEA/hG6i2jE7Vd68XOnlNvMOM2xwHhFhnR0mwrKIWHAViTFcqJq5q82HU3US0ITzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VJSCM12QPz4f3nVC for ; Tue, 16 Apr 2024 10:09:19 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 05B3F1A0568 for ; Tue, 16 Apr 2024 10:09:28 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g7U3R1mMNVnKA--.11112S8; Tue, 16 Apr 2024 10:09:27 +0800 (CST) From: Yu Kuai To: linux-block@vger.kernel.org, saranyamohan@google.com, axboe@kernel.dk, tj@kernel.org Cc: yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH blktests 4/5] tests/throtl: add a new test 004 Date: Tue, 16 Apr 2024 10:00:41 +0800 Message-Id: <20240416020042.509291-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416020042.509291-1-yukuai1@huaweicloud.com> References: <20240416020042.509291-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g7U3R1mMNVnKA--.11112S8 X-Coremail-Antispam: 1UD129KBjvJXoW7ur43Zw4xKw1xtFW5ArWfuFg_yoW5JF1xpr WUGa1Fyr4xCFnIqr13KanrZayrZws5Zr4Sy3srJr1SyFyjq34UJr1Ikr1SvFZ5CF9xWryr ZF48XrWfK3W8GrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQSdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: 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()") Signed-off-by: Yu Kuai --- 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 From patchwork Tue Apr 16 02:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13631082 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91CFB101F7 for ; Tue, 16 Apr 2024 02:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233378; cv=none; b=K1mSNChD+VaVv2vNi7PGiYlTYvnmXhaErXM//JNt29+g89zLWeHV4mkG82EGGQ3Lx5aWQfHQigsuSHupi/t26ed2NFmxfgZpzh6TUpW0Bi6SiiNxUZrJT0hN6aurzCS6FU9u/pyJoEd2rdQ3aW+LUU+rLY2R1AgbNOHk0bkNoFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233378; c=relaxed/simple; bh=+VXmHkl213wIRecrSZqEMt4BydB/UNzEFVl5mcTm5IQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qFuLxJtXdZSFBYNbl3oksbFJBXjsR5w6Si2HNgsfnM4Qt9JvI6+D44sN4hLnP/K8HXvk9KVc5j9cTXFidqDUjVQIywFB9JHErpVz1MHbvicJrmlvcuwct8gM7zq7ANZJ7jqXqjR6dZb7pwmdcwbMhmh1YdM2CSGm2cdJDLJbpFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VJSCR5LBsz4f3lXl for ; Tue, 16 Apr 2024 10:09:23 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 57D241A10BA for ; Tue, 16 Apr 2024 10:09:28 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g7U3R1mMNVnKA--.11112S9; Tue, 16 Apr 2024 10:09:28 +0800 (CST) From: Yu Kuai To: linux-block@vger.kernel.org, saranyamohan@google.com, axboe@kernel.dk, tj@kernel.org Cc: yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH blktests 5/5] tests/throtl: add a new test 005 Date: Tue, 16 Apr 2024 10:00:42 +0800 Message-Id: <20240416020042.509291-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416020042.509291-1-yukuai1@huaweicloud.com> References: <20240416020042.509291-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g7U3R1mMNVnKA--.11112S9 X-Coremail-Antispam: 1UD129KBjvJXoW7tw13KryrJr48CF4rtryftFb_yoW8KFy7pa y7CF4rKw48WFsxtr43Ka17WFWfXws5Ar4xA3srGr1FyF12q34UKr1Iyw1xtF93tFnxuryr Za4rXFWkKF18urDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQSdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai 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 --- 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