From patchwork Wed Apr 17 02:20: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: 13632807 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 34BED63A9 for ; Wed, 17 Apr 2024 02:28:55 +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=1713320938; cv=none; b=MeAt4RV1JkWF/2ptZcwbWM36SZvk3rsK5U5iG9qldWAXMg3OaQfnpteeh6jkA+gC7im8OIN6vXr6fg7z/FXY+2hscqLBHf2RvmgpBYYIhc+mC7V9QDRNg/a8NhB9/BM8D83EV1GTWZ5a1PihTH/03Nl1rvh8BnCCvQOeT49xc74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713320938; c=relaxed/simple; bh=Rs53PvVtWoj89AYAR6ac06EuH4mNAwmWrIzPjqdd988=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z88PCN/3thL2IKse29rJjFoCdzHeIplCY1B5/bmqLwx9a6Rx7vbW63Zju8AZhBjj1urVesYkvaK7j1jOlfeC9Pl9HIPyFrOSjaB01K09FkWqY1rE2QlXe7olIrNdlDkw/v7lMY+bew+6Ua/fB/BqhiROWmlF5TIBQ2oPAjMr9dg= 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 4VK4bN2BySz4f3kkP for ; Wed, 17 Apr 2024 10:28:48 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id E65A81A016E for ; Wed, 17 Apr 2024 10:28:52 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHiMx9mtJvAKA--.38748S5; Wed, 17 Apr 2024 10:28:52 +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 v2 blktests 1/5] tests/throtl: add first test for blk-throttle Date: Wed, 17 Apr 2024 10:20:01 +0800 Message-Id: <20240417022005.1410525-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240417022005.1410525-1-yukuai1@huaweicloud.com> References: <20240417022005.1410525-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: cCh0CgBHGBHiMx9mtJvAKA--.38748S5 X-Coremail-Antispam: 1UD129KBjvJXoWxGw18KrWDWrykKryktr1kKrg_yoW5ZF45p3 yUWFWFkr4xGFsrtr13K3W29a4rZw4kAFW7A3srGr15Zr42qrWUtF1Iyr1YyFWfJFy7WFWr Za10qFWkK3WUZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 | 39 ++++++++++++++++++++++++ tests/throtl/001.out | 6 ++++ tests/throtl/rc | 71 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 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..739efe2 --- /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_test nr_devices=1; then + return 1; + fi + + bps_limit=$((1024 * 1024)) + + _set_limits wbps=$bps_limit + _test_io write 4k 256 + _remove_limits + + _set_limits wiops=256 + _test_io write 4k 256 + _remove_limits + + _set_limits rbps=$bps_limit + _test_io read 4k 256 + _remove_limits + + _set_limits riops=256 + _test_io read 4k 256 + _remove_limits + + _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..871102c --- /dev/null +++ b/tests/throtl/rc @@ -0,0 +1,71 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Yu Kuai +# +# Tests for blk-throttle + +. common/rc +. common/null_blk + +CG=/sys/fs/cgroup +TEST_DIR=$CG/blktests_throtl +devname=nullb0 + +group_requires() { + _have_root + _have_null_blk + _have_kernel_option BLK_DEV_THROTTLING + _have_cgroup2_controller io +} + +# Create a new null_blk device, and create a new blk-cgroup for test. +_set_up_test() { + if ! _init_null_blk "$*"; then + return 1; + fi + + 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 +} + +_set_limits() { + dev=$(cat /sys/block/$devname/dev) + echo "$dev $*" > $TEST_DIR/io.max +} + +_remove_limits() { + dev=$(cat /sys/block/$devname/dev) + echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_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. +_test_io() { + { + sleep 0.1 + start_time=$(date +%s.%N) + + if [ "$1" == "read" ]; then + dd if=/dev/$devname of=/dev/null bs="$2" count="$3" iflag=direct status=none + elif [ "$1" == "write" ]; then + dd of=/dev/$devname 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" > $TEST_DIR/cgroup.procs + wait $pid +} From patchwork Wed Apr 17 02:20: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: 13632811 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 A60FC79FE for ; Wed, 17 Apr 2024 02:29:01 +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=1713320944; cv=none; b=BGYmx+FReWge5HhaHer+6JfAUO/+0JqhXLGcdVDmHZrrRytejiTvhTm2E1IjKXFlIAzJE0iiZOzqL4IkKrMuGX4kUrNExxrgPe5+hadQIU2P4FMAS5femhZdsaZRgTlXXIRHVlyCaFrUhVDlEW+Vb8GdHoA08+i66HNqFg4/M0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713320944; c=relaxed/simple; bh=ZilNktfcTDIwUUPk10/qrvvnUQE4wcKVythWlrnq1Ew=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CLeGxjJZplq+6dwrqOUUSCAvYz7hGtm1C/q1Q1crmGvVGSE+rmT8i7UMGzgQEwp4K8yD+rFNQUE/vgLy51JnEmySN3gkHYhL8GBYeVoCXaDrOULkSbTZT4Z3H+rDyOKZvzlN35qlXeYU93tWsWDSX3XelFGIt1X3n3lfrz/DUos= 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VK4bL0YQHz4f3jJD for ; Wed, 17 Apr 2024 10:28:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 411F71A0BE2 for ; Wed, 17 Apr 2024 10:28:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHiMx9mtJvAKA--.38748S6; Wed, 17 Apr 2024 10:28:53 +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 v2 blktests 2/5] tests/throtl: add a new test 002 Date: Wed, 17 Apr 2024 10:20:02 +0800 Message-Id: <20240417022005.1410525-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240417022005.1410525-1-yukuai1@huaweicloud.com> References: <20240417022005.1410525-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: cCh0CgBHGBHiMx9mtJvAKA--.38748S6 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw4DZw1DXF1fuw4UurWUXFb_yoW8GF47pa y7KayFkF4xWFnrJry3G3W29a4rZws5Zr47A343Wr15ZFyqqw17KF1Iyr1SyFZ3JrW29r1F 93WvqFZ5GF4DAa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 | 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..83cd27f --- /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_test max_sectors=8; then + return 1; + fi + + _set_limits wiops=256 + _test_io write 1M 1 + _remove_limits + + _set_limits riops=256 + _test_io read 1M 1 + _remove_limits + + _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 Wed Apr 17 02:20: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: 13632806 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 C86FB63CB for ; Wed, 17 Apr 2024 02:28:56 +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=1713320938; cv=none; b=L88MQO+a7DtSplW4DJiLzxddXpYgCHspFOgmhRSSR5ebsHdq5FLxj08BIpqN3CfQe/sNRGmzaKQ4GyB3LlJ++XvmZY3rSwaTw1YcUKcdkzMByC/X6RWBZ532DD7pT13moVYkUVKYZ+VOpCDh4E3tkzywLyYqePMn9e7PIMuLpGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713320938; c=relaxed/simple; bh=YL0ObOK5sPewSKe0oyK5ramBDsXlgInE1mhUljGimVo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fVYAd1IwQ2n+r7YWVsmmT+rg1JpsONmaoVf0lMS9YMy6XewASH5XFjcxHxqeIkJF6dX5R1qtepbzCy/biz1bp0BH1R5IFwujPBjgVCINNkmmP4Kd6PZ6C2fUuxC53kiZ/ZPHqtamMMIjH31J8eguQ/K5wh4KOoEDFZRA7IrfC0U= 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 4VK4bJ4xk8z4f3mJ5 for ; Wed, 17 Apr 2024 10:28:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 955EA1A0179 for ; Wed, 17 Apr 2024 10:28:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHiMx9mtJvAKA--.38748S7; Wed, 17 Apr 2024 10:28:53 +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 v2 blktests 3/5] tests/throtl: add a new test 003 Date: Wed, 17 Apr 2024 10:20:03 +0800 Message-Id: <20240417022005.1410525-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240417022005.1410525-1-yukuai1@huaweicloud.com> References: <20240417022005.1410525-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: cCh0CgBHGBHiMx9mtJvAKA--.38748S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr4DJFW3CFyxAw1UtF1kKrg_yoW8GFyxp3 y2kayrKr4xKFnrJr4fGa17WayfZws5Zr47Aw1xWr13ZFyIq345Wr1Iyr1SyFZ3JF12qr1r Z3WjqFZ5KFsrJFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 | 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..806b602 --- /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_test max_sectors=8; then + return 1; + fi + + limit=$((1024 * 1024)) + + _set_limits wbps=$limit + _test_io write 1M 1 + _remove_limits + + _set_limits rbps=$limit + _test_io read 1M 1 + _remove_limits + + _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 Wed Apr 17 02:20: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: 13632809 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 0549A6FA8 for ; Wed, 17 Apr 2024 02:28:56 +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=1713320938; cv=none; b=ruRYLMS7Gy5UmjiLnnpzMKo2Qkc9WkREwkYAXZBmwjKpaTnW/znFwL78J5fCmSOwgLh1YvSmGF3aQYoCkUHsuRcjKP5WC8yNradNHOLIHHuozctKSgcZajcqPmCRoveTCo0QmgP75zRjKDRWM17VQd3voroaezF8qAJU8MCoRk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713320938; c=relaxed/simple; bh=Vgv55XaMpM+582oe5iGGYUY4yeDTxWAZXfZLzwQOUpU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BWFtZ5at3DDqiFPBaTXhv4jafRD2cwigXs3KAT2JE2/pJqEQ9XNqifsBpnDdjdCxU+Hx0VauBQFg/iquhsYLNB3uH73uIkp87OLWt5THlGMr5VjJFKbEATFCnZJSZSYFuvf1hlP4HxTZkgGYa+2dWLu5fbBVbt5Uf9KN0a+VYRU= 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 4VK4bK0Gmtz4f3nKV for ; Wed, 17 Apr 2024 10:28:45 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id EA3331A0175 for ; Wed, 17 Apr 2024 10:28:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHiMx9mtJvAKA--.38748S8; Wed, 17 Apr 2024 10:28:53 +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 v2 blktests 4/5] tests/throtl: add a new test 004 Date: Wed, 17 Apr 2024 10:20:04 +0800 Message-Id: <20240417022005.1410525-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240417022005.1410525-1-yukuai1@huaweicloud.com> References: <20240417022005.1410525-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: cCh0CgBHGBHiMx9mtJvAKA--.38748S8 X-Coremail-Antispam: 1UD129KBjvJXoWxAr1xKrWxZFyDGw1UtFWkWFg_yoW5tw4xpr WUCF4Fyr4xAFnrZr13G3ZI9FWfZr4kAFWxA3srCr15AF1jgrW8tF12kr10vFWrCF9rWryr ZF48XFWxKa18ZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 | 37 +++++++++++++++++++++++++++++++++++ tests/throtl/004.out | 4 ++++ tests/throtl/rc | 46 +++++++++++++++++++++++++++++++++----------- 3 files changed, 76 insertions(+), 11 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..f2567c0 --- /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_test_by_configfs power=1; then + return 1; + fi + + _set_limits wbps=$((1024 * 1024)) + + { + sleep 0.1 + _issue_io write 10M 1 + } & + + pid=$! + echo "$pid" > $TEST_DIR/cgroup.procs + + sleep 1 + echo 0 > /sys/kernel/config/nullb/$devname/power + wait "$pid" + + _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 diff --git a/tests/throtl/rc b/tests/throtl/rc index 871102c..f70e250 100644 --- a/tests/throtl/rc +++ b/tests/throtl/rc @@ -30,6 +30,21 @@ _set_up_test() { return 0; } +_set_up_test_by_configfs() { + if ! _init_null_blk nr_devices=0; then + return 1; + fi + + if ! _configure_null_blk $devname "$*"; then + return 1; + fi + + echo +io > $CG/cgroup.subtree_control + mkdir $TEST_DIR + + return 0; +} + _clean_up_test() { rmdir $TEST_DIR echo -io > $CG/cgroup.subtree_control @@ -46,23 +61,32 @@ _remove_limits() { echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max } +_issue_io() +{ + start_time=$(date +%s.%N) + + if [ "$1" == "read" ]; then + dd if=/dev/$devname of=/dev/null bs="$2" count="$3" iflag=direct status=none + elif [ "$1" == "write" ]; then + dd of=/dev/$devname 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. _test_io() { { - sleep 0.1 - start_time=$(date +%s.%N) + rw=$1 + bs=$2 + count=$3 - if [ "$1" == "read" ]; then - dd if=/dev/$devname of=/dev/null bs="$2" count="$3" iflag=direct status=none - elif [ "$1" == "write" ]; then - dd of=/dev/$devname 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" + sleep 0.1 + _issue_io "$rw" "$bs" "$count" } & pid=$! From patchwork Wed Apr 17 02:20: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: 13632808 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 7AB546FBE for ; Wed, 17 Apr 2024 02:28:57 +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=1713320938; cv=none; b=F3XP7ChDrTSNUfCsj9zcL5aLV1SXlSEgD81w+Jmjo4VToWAh0JOFiuUPQr1a3vlzLzjKxoRlCtCXnEoOGfQoER+YY2W1zBkpO3mV/RW1Mt86IInpwLJ96hKzfj/5D9O/uBwV72yxb4Fstq9HUiw3NC2MOreYiz7N4wYW+U86Yqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713320938; c=relaxed/simple; bh=M/yDhWAvN868jyzyqCs8S/BdaNUmTOLOiP2hKqzU270=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fHHCBpbio4BIzKJvlRuqQ8F7ktPEh5sPL4Miq/qg2nfRyFPohtwP//6X+G8kOPdIm6DXUs9BLGtxdPTQK79iS8EKq966+kqIc05h62YCf8tFk6oE9CJjslpRhtEI2/maZWSxxofKDUctSeeBo/7E1iNUoZitQKxyFAPNL0jh7as= 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 4VK4bP4dbXz4f3mW2 for ; Wed, 17 Apr 2024 10:28:49 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 465D91A058D for ; Wed, 17 Apr 2024 10:28:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHiMx9mtJvAKA--.38748S9; Wed, 17 Apr 2024 10:28:54 +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 v2 blktests 5/5] tests/throtl: add a new test 005 Date: Wed, 17 Apr 2024 10:20:05 +0800 Message-Id: <20240417022005.1410525-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240417022005.1410525-1-yukuai1@huaweicloud.com> References: <20240417022005.1410525-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: cCh0CgBHGBHiMx9mtJvAKA--.38748S9 X-Coremail-Antispam: 1UD129KBjvJXoW7tw13KryrJF48Wr4xtrWfAFb_yoW8XrW3pa y2ka1Fkw4xWFnrKr4fGa17WayrZr4kZr4UA3srWr13ZFyjq34UGFn2gw1IyrZayFnrZryx u3W0qFW8KF4UZa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 | 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..5ee5e7d --- /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_test nr_devices=1; then + return 1; + fi + + _set_limits wbps=$((512 * 1024)) + + { + sleep 0.1 + _issue_io write 1M 1 + } & + + pid=$! + echo "$pid" > $TEST_DIR/cgroup.procs + + sleep 1 + _set_limits wbps=$((256 * 1024)) + wait $pid + _remove_limits + + _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