From patchwork Sat Apr 20 08:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13637065 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 45F7014A8D for ; Sat, 20 Apr 2024 08:54:07 +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=1713603249; cv=none; b=JwlKwtxkMvfKQv8jVPtizZn/VodVcAdxqg+aATu9cQtJ9MXkE9WqNSHg10p/kr/ea46UPBV3uGTAmxapJRSgL8wMONA409T5wo22Rt+yz2wdvx8iPBKwW4PuvYHYqv5bV8EHyO6IKejMKdZi1rGU8ZRKR22go5zU2Sa51XqQbCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; c=relaxed/simple; bh=RjP/I5NNOFTjSZRoYqzsuleNX4tChazXWCb5zE60qzA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZcU6mo12oMefafULagLZrJGI+wQcltWC0tczW1CBgS642/fze53T6cS+a7gBlnaBpMKfX45wI+LeRd0AHUwP+UAJxfGfJ4mWWNjuK/xZXdEUXbk0dp4hhEGYs5l+mxkwH7b3AsG9nizkZ8l6U/PYNqyr6QWm7eGY/NN22tufLtg= 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 4VM50L5p1sz4f3lCm for ; Sat, 20 Apr 2024 16:53:54 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id D355B1A0568 for ; Sat, 20 Apr 2024 16:54:03 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBGqgiNmW_HiKQ--.35908S5; Sat, 20 Apr 2024 16:54:03 +0800 (CST) From: Yu Kuai To: saranyamohan@google.com, tj@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH v3 blktests 1/5] tests/throtl: add first test for blk-throttle Date: Sat, 20 Apr 2024 16:45:01 +0800 Message-Id: <20240420084505.3624763-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240420084505.3624763-1-yukuai1@huaweicloud.com> References: <20240420084505.3624763-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: cCh0CgBHGBGqgiNmW_HiKQ--.35908S5 X-Coremail-Antispam: 1UD129KBjvJXoWxuFyUCr4ruF47Cr4xZw18Xwb_yoWrGF1fpr WUua1rKw4xJFsFyr13K3WUZFWrAws7ZF47A3srGr1Yyr47tw4Ygw42yryUXFWfAFnrXr4r Za18ZFWrCF1DZ3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r106r15McIj6xkF7I0En7xvr7AKxVWUJVW8JwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUDManUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Test basic functionality. Signed-off-by: Yu Kuai --- tests/throtl/001 | 39 ++++++++++++++++++++ tests/throtl/001.out | 6 +++ tests/throtl/rc | 88 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 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..835cac2 --- /dev/null +++ b/tests/throtl/001 @@ -0,0 +1,39 @@ +#!/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 + +test() { + echo "Running ${TEST_NAME}" + + if ! _set_up_throtl; then + return 1; + fi + + local bps_limit=$((1024 * 1024)) + + _throtl_set_limits wbps=$bps_limit + _throtl_test_io write 4k 256 + _throtl_remove_limits + + _throtl_set_limits wiops=256 + _throtl_test_io write 4k 256 + _throtl_remove_limits + + _throtl_set_limits rbps=$bps_limit + _throtl_test_io read 4k 256 + _throtl_remove_limits + + _throtl_set_limits riops=256 + _throtl_test_io read 4k 256 + _throtl_remove_limits + + _clean_up_throtl + 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..2ddbac8 --- /dev/null +++ b/tests/throtl/rc @@ -0,0 +1,88 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Yu Kuai +# +# Tests for blk-throttle + +. common/rc +. common/null_blk +. common/cgroup + +THROTL_DIR=$(echo "$TEST_NAME" | tr '/' '_') +THROTL_DEV=dev_nullb + +group_requires() { + _have_root + _have_null_blk + _have_kernel_option BLK_DEV_THROTTLING + _have_cgroup2_controller io + _have_program bc +} + +# Create a new null_blk device, and create a new blk-cgroup for test. +_set_up_throtl() { + + if ! _configure_null_blk $THROTL_DEV "$@" power=1; then + return 1 + fi + + if ! _init_cgroup2; then + _exit_null_blk + return 1 + fi + + echo "+io" > "$(_cgroup2_base_dir)/cgroup.subtree_control" + echo "+io" > "$CGROUP2_DIR/cgroup.subtree_control" + + mkdir -p "$CGROUP2_DIR/$THROTL_DIR" + return 0; +} + +_clean_up_throtl() { + rmdir "$CGROUP2_DIR/$THROTL_DIR" + echo "-io" > "$CGROUP2_DIR/cgroup.subtree_control" + echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control" + + _exit_cgroup2 + _exit_null_blk +} + +_throtl_set_limits() { + echo "$(cat /sys/block/$THROTL_DEV/dev) $*" > \ + "$CGROUP2_DIR/$THROTL_DIR/io.max" +} + +_throtl_remove_limits() { + echo "$(cat /sys/block/$THROTL_DEV/dev) rbps=max wbps=max riops=max wiops=max" > \ + "$CGROUP2_DIR/$THROTL_DIR/io.max" +} + +# Create an asynchronous thread and bind it to the specified blk-cgroup, issue +# IO and then print time elapsed to the second, blk-throttle limits should be +# set before this function. +_throtl_test_io() { + local pid + + { + local start_time + local end_time + local elapsed + + sleep 0.1 + start_time=$(date +%s.%N) + + if [ "$1" == "read" ]; then + dd if=/dev/$THROTL_DEV of=/dev/null bs="$2" count="$3" iflag=direct status=none + elif [ "$1" == "write" ]; then + dd of=/dev/$THROTL_DEV if=/dev/zero bs="$2" count="$3" oflag=direct status=none + fi + + end_time=$(date +%s.%N) + elapsed=$(echo "$end_time - $start_time" | bc) + printf "%.0f\n" "$elapsed" + } & + + pid=$! + echo "$pid" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs" + wait $pid +} From patchwork Sat Apr 20 08:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13637066 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 3755C14A83 for ; Sat, 20 Apr 2024 08:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; cv=none; b=rAAirem/NPW40iGam3LVsYGOpLJ4FfvLSIbrl1Z1910lNWtEfFwJI1yNHDW31PljIWIfeoEDZY+lxKzt8QoymaTfLoo1QI9wNZTMfGpJ7tp0jRsWImCVGsBzT/reW4mt3F0fV+CxbJlhiQjTb9hnRjehq4plwE+7/mGiBlSEfJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; c=relaxed/simple; bh=6VofsT0Owod0SwNu1JDal8Ks16T7IBAuM6dwAj6s3Ko=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jyB3+3nCn8WxdObH04iSYzmAYmBEeBmDxTX8vwa/Zf6eqSf+xyATj0ZWCVrIubJmYJRnvLbfjrndR2VpWlKnJ4nTTCsaEE7seZzoIfj+lvZ9T6DlaA0q1wtYGKMWJli/k0PkyWG+f/euStld1jyPZzuH32CUhzdEf9O1Cwt9mJU= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VM50N61tVz4f3khn for ; Sat, 20 Apr 2024 16:53:56 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 2F5191A0175 for ; Sat, 20 Apr 2024 16:54:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBGqgiNmW_HiKQ--.35908S6; Sat, 20 Apr 2024 16:54:04 +0800 (CST) From: Yu Kuai To: saranyamohan@google.com, tj@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH v3 blktests 2/5] tests/throtl: add a new test 002 Date: Sat, 20 Apr 2024 16:45:02 +0800 Message-Id: <20240420084505.3624763-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240420084505.3624763-1-yukuai1@huaweicloud.com> References: <20240420084505.3624763-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: cCh0CgBHGBGqgiNmW_HiKQ--.35908S6 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw4DZw1DXF1fuw4UurWUXFb_yoW8Xr1Up3 y7Ka1rKF4IgF9rJry3G3W7uayFyws3Zr47Aw13Xr15Zr1qqw17KF1Ivr1SyFWfJFZrur1F 93WvqFWrGF4DJ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r106r15McIj6xkF7I0En7xvr7AKxVWUJVW8JwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JU29aPUUUUU = 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 | 30 ++++++++++++++++++++++++++++++ tests/throtl/002.out | 4 ++++ 2 files changed, 34 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..8bbe18b --- /dev/null +++ b/tests/throtl/002 @@ -0,0 +1,30 @@ +#!/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 + +test() { + echo "Running ${TEST_NAME}" + + if ! _set_up_throtl max_sectors=8; then + return 1; + fi + + _throtl_set_limits wiops=256 + _throtl_test_io write 1M 1 + _throtl_remove_limits + + _throtl_set_limits riops=256 + _throtl_test_io read 1M 1 + _throtl_remove_limits + + _clean_up_throtl + 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 Sat Apr 20 08:45:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13637063 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 907AAF9DF for ; Sat, 20 Apr 2024 08:54:07 +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=1713603249; cv=none; b=cwGZY9MEJvWZRQinBttc9akyGwK6TVYjpxgkCsI/lJvDPt53hkzNbrKPjd5MWs99/ZOuGALKWHXh9pZzdAmjA4NiWQONk4KGN34Cwn4Qdi9ZGo9qVDRb1QFN6ht0YDSYhvaVMcskGAFHpe3nbJR1GoJCYmuVel9l2rdgdciOIIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; c=relaxed/simple; bh=3kZshLD7u9/MfOH3AKlJZe6uQ7/2EfOz7EVdqWcKpaU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qpiyPfEzhVVq62CuTaFOKYSULV11RmFgJbVfiAD7uysjYGbBeNK5MZvgfT1stOEhWKQ0mduOTPJk8Emou1pVJiXRasEPps2MoAZsuYEHXvBQKzvWtHnEzF/pwRdfiiRhv6fAu2ua4/uxc9z5hBsfiDWKpjI9VDfTnbVPhGp5DZI= 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 4VM50R5RYbz4f3jkd for ; Sat, 20 Apr 2024 16:53:59 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 7DBBD1A0C47 for ; Sat, 20 Apr 2024 16:54:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBGqgiNmW_HiKQ--.35908S7; Sat, 20 Apr 2024 16:54:04 +0800 (CST) From: Yu Kuai To: saranyamohan@google.com, tj@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH v3 blktests 3/5] tests/throtl: add a new test 003 Date: Sat, 20 Apr 2024 16:45:03 +0800 Message-Id: <20240420084505.3624763-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240420084505.3624763-1-yukuai1@huaweicloud.com> References: <20240420084505.3624763-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: cCh0CgBHGBGqgiNmW_HiKQ--.35908S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr4DJFW3CFyxAw1UtF1kKrg_yoW8Xr43pa y2kayrKr4IgFnrAr4fGa17WayfAws3Zr17Aw13Wr13uFW2q3y5WF1Ivr1YvFWfJFsFqr1r Z3WUZF95CF1DJrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r106r15McIj6xkF7I0En7xvr7AKxVWUJVW8JwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUHOJ5UUUUU = 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 | 32 ++++++++++++++++++++++++++++++++ tests/throtl/003.out | 4 ++++ 2 files changed, 36 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..da4342e --- /dev/null +++ b/tests/throtl/003 @@ -0,0 +1,32 @@ +#!/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 +# commit 111be8839817 ("block-throttle: avoid double charge") + +. tests/throtl/rc + +DESCRIPTION="bps limit over IO split" +QUICK=1 + +test() { + echo "Running ${TEST_NAME}" + + if ! _set_up_throtl max_sectors=8; then + return 1; + fi + + local limit=$((1024 * 1024)) + + _throtl_set_limits wbps=$limit + _throtl_test_io write 1M 1 + _throtl_remove_limits + + _throtl_set_limits rbps=$limit + _throtl_test_io read 1M 1 + _throtl_remove_limits + + _clean_up_throtl + 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 Sat Apr 20 08:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13637064 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 7EF0BC8C7 for ; Sat, 20 Apr 2024 08:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; cv=none; b=suNXUMWc/PpBHRaxVoLwvE9I459iptgN5W1x60M6QVM/mVe90ePtOUJ6ga/TCzdSPYGR3+otwLat+ydNf7AUIFoM6im6hmjVrpJUce74jWHnQ+J55e8dZlCex/pB/Ah1Q8zISe0/SIRhACnYEP/25MRTUVfcwBW+b50qp/zbUec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; c=relaxed/simple; bh=iYm4fXi54gLhCOnn0xUUW7yMkltuZ0/OPezsxkAVd+s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=flaJbfw5ATiuBy72NE0hSkxP+Tlz+/Li1U1qkebQOQN+0LdQH0W0GQ0vWRRoFn3+Jsp0VkD1vi96ZOw4dSCmPEOfxfdcJ35bN/4NyJLobuqubYZ82jJ9n8gEOTBsqmnvwYlVvo6eaj/mU7t/IrtcEity0aOXj51tDVvxE9ROeg4= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VM50P3bC2z4f3khv for ; Sat, 20 Apr 2024 16:53:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id D02BC1A0568 for ; Sat, 20 Apr 2024 16:54:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBGqgiNmW_HiKQ--.35908S8; Sat, 20 Apr 2024 16:54:04 +0800 (CST) From: Yu Kuai To: saranyamohan@google.com, tj@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH v3 blktests 4/5] tests/throtl: add a new test 004 Date: Sat, 20 Apr 2024 16:45:04 +0800 Message-Id: <20240420084505.3624763-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240420084505.3624763-1-yukuai1@huaweicloud.com> References: <20240420084505.3624763-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: cCh0CgBHGBGqgiNmW_HiKQ--.35908S8 X-Coremail-Antispam: 1UD129KBjvJXoWxAr1xKrWxZFyDGw1UAFy5Jwb_yoW5uF48pr WrCF4rKw4fA3ZFkr13W3ZFvFWruws5ZrW3A347Cr4YyF47XrW8t3WIyr10qFyrCF9rXrWr ZF48XFW8KF4UZ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VCY1x0262k0Y48FwI0_Jr0_Gr1lYx0Ex4A2jsIE14v26r1j 6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI 8I648v4I1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUOa0P DUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Test delete the disk while IO is throttled, regression 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 | 37 +++++++++++++++++++++++++++++++++++++ tests/throtl/004.out | 4 ++++ tests/throtl/rc | 36 ++++++++++++++++++++++-------------- 3 files changed, 63 insertions(+), 14 deletions(-) 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..6e28612 --- /dev/null +++ b/tests/throtl/004 @@ -0,0 +1,37 @@ +#!/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 + +test() { + echo "Running ${TEST_NAME}" + + if ! _set_up_throtl; then + return 1; + fi + + _throtl_set_limits wbps=$((1024 * 1024)) + + { + sleep 0.1 + _throtl_issue_io write 10M 1 + } & + + local pid=$! + echo "$pid" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs" + + sleep 0.6 + echo 0 > "/sys/kernel/config/nullb/$THROTL_DEV/power" + wait "$pid" + + _clean_up_throtl + echo "Test complete" +} diff --git a/tests/throtl/004.out b/tests/throtl/004.out new file mode 100644 index 0000000..e76ec3a --- /dev/null +++ b/tests/throtl/004.out @@ -0,0 +1,4 @@ +Running throtl/004 +dd: error writing '/dev/dev_nullb': Input/output error +1 +Test complete diff --git a/tests/throtl/rc b/tests/throtl/rc index 2ddbac8..2e26fd2 100644 --- a/tests/throtl/rc +++ b/tests/throtl/rc @@ -57,6 +57,24 @@ _throtl_remove_limits() { "$CGROUP2_DIR/$THROTL_DIR/io.max" } +_throtl_issue_io() { + local start_time + local end_time + local elapsed + + start_time=$(date +%s.%N) + + if [ "$1" == "read" ]; then + dd if=/dev/$THROTL_DEV of=/dev/null bs="$2" count="$3" iflag=direct status=none + elif [ "$1" == "write" ]; then + dd of=/dev/$THROTL_DEV if=/dev/zero bs="$2" count="$3" oflag=direct status=none + fi + + end_time=$(date +%s.%N) + elapsed=$(echo "$end_time - $start_time" | bc) + printf "%.0f\n" "$elapsed" +} + # Create an asynchronous thread and bind it to the specified blk-cgroup, issue # IO and then print time elapsed to the second, blk-throttle limits should be # set before this function. @@ -64,22 +82,12 @@ _throtl_test_io() { local pid { - local start_time - local end_time - local elapsed + local rw=$1 + local bs=$2 + local count=$3 sleep 0.1 - start_time=$(date +%s.%N) - - if [ "$1" == "read" ]; then - dd if=/dev/$THROTL_DEV of=/dev/null bs="$2" count="$3" iflag=direct status=none - elif [ "$1" == "write" ]; then - dd of=/dev/$THROTL_DEV if=/dev/zero bs="$2" count="$3" oflag=direct status=none - fi - - end_time=$(date +%s.%N) - elapsed=$(echo "$end_time - $start_time" | bc) - printf "%.0f\n" "$elapsed" + _throtl_issue_io "$rw" "$bs" "$count" } & pid=$! From patchwork Sat Apr 20 08:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13637067 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 6310F14A98 for ; Sat, 20 Apr 2024 08:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; cv=none; b=rkxuIgU2oTVmQAxNSmCW7hTCpv3nMcPZWRordvH270MfFYS71g2mBjPlhRlsPlYj5LW7SHfSR9EnNH4ra3QvYzOSc6OQrL5sHxp81YStrfas5rjlNTKNQe0VqRE67Yq7aOyqBp7SWGapm4HZ1EsjLhySfTRfCRtwbzwVyIbF/PU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713603249; c=relaxed/simple; bh=JX7BtuFfZ7/4NyL0YAncpwD7Gm2nyvXz8Lsh2PXvbMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Dxa2ne/Kq1CpFhFQ2ClqNqTBv705SW8mbKwi5WxwwWDQM2RvVEJIzJPL3ach4JOazER+xxpnb6Zn0lckWU5ioh89Y67m+GUZS0pR2XuwWA62SPMQmo0HPIGYHejYshhumZBRDvWq1rilfLq6e/StQLsQX5H1325fKD69ogr3RxU= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VM50P5y6Nz4f3khy for ; Sat, 20 Apr 2024 16:53:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 2EE281A0175 for ; Sat, 20 Apr 2024 16:54:05 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBGqgiNmW_HiKQ--.35908S9; Sat, 20 Apr 2024 16:54:05 +0800 (CST) From: Yu Kuai To: saranyamohan@google.com, tj@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yangerkun@huawei.com Subject: [PATCH v3 blktests 5/5] tests/throtl: add a new test 005 Date: Sat, 20 Apr 2024 16:45:05 +0800 Message-Id: <20240420084505.3624763-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240420084505.3624763-1-yukuai1@huaweicloud.com> References: <20240420084505.3624763-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: cCh0CgBHGBGqgiNmW_HiKQ--.35908S9 X-Coremail-Antispam: 1UD129KBjvJXoW7tw13KryrJF48Wr4xtrWfAFb_yoW8XFWDpa y2ka1rKw4xWFnrKr1fGa17WFWrAw4kZr47A347Wr13ZFyjq3yUGr129w1IyFZ3tFnrZryx uF10qrW8KF4UA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VCY1x0262k0Y48FwI0_Jr0_Gr1lYx0Ex4A2jsIE14v26r1j 6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI 8I648v4I1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUOa0P DUUUU 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 | 37 +++++++++++++++++++++++++++++++++++++ tests/throtl/005.out | 3 +++ 2 files changed, 40 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..0778258 --- /dev/null +++ b/tests/throtl/005 @@ -0,0 +1,37 @@ +#!/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 + +test() { + echo "Running ${TEST_NAME}" + + if ! _set_up_throtl; then + return 1; + fi + + _throtl_set_limits wbps=$((512 * 1024)) + + { + sleep 0.1 + _throtl_issue_io write 1M 1 + } & + + local pid=$! + echo "$pid" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs" + + sleep 1 + _throtl_set_limits wbps=$((256 * 1024)) + wait $pid + _throtl_remove_limits + + _clean_up_throtl + 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