Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp189917rwb; Mon, 28 Nov 2022 19:07:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4xtLlVgsA8VcU4ZQU/2gYziK6erieSpF1BzdggRrTP5b8YJQ73GeMgpHEA5XSD0GM/4BLi X-Received: by 2002:a63:4c7:0:b0:477:f9fa:d411 with SMTP id 190-20020a6304c7000000b00477f9fad411mr12946176pge.117.1669691247560; Mon, 28 Nov 2022 19:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669691247; cv=none; d=google.com; s=arc-20160816; b=e7fGKGzc0pZc+3MmGH1XCEpbXpC16Vnb0/p1ARljKF03wvyKPcwoGZ19EYj0EBxiYg 6SnbYjNnCZNZ2QvlCHutyvks+w4yw5405gCSqOcrhgeVu78hUTpvOMq+VAMJZ9OjR1Vv MOM+VlGn6tJ2WkQ3N+KlF7sz7JP0vsjKMpQgb/trBnfaaE0VtXxIuBwdXJ0bG/yyd7rh ntZN0pIO6L3v3U/ABddicqQ37/p3nU/9QYjcvinAvnoJP9GSNyuQu37U2kB/idlb7xo/ LXzb6WsfT1hKkW4xZaK2qzjO8btPo0C0bKRGwMBYzV00cWg4oW5muF44QMB5KaOKQxHG yJPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=SYJSGdVEgApKM1c+RztiM2bdceMQvV9vJgYHprNhZbI=; b=VULGEdhhvc7oFAOQSxImNnTeVIs9YanBapM25cc2PftoEt0FlkKSKVGJnLwYR6XUgm crwOeuyx3+UPTjlgN8qNq9cr5bl1GP4L8qGG2dBQQ9xuDzVatGEbrnixWmnZHj6tSbPf EUAkBDmyoX8ZjBTj9Z2LwRUTNrR0777xAozr7NMycqS2QYAh4azTFNLMmLRiBiCqm13t 3nKDpLPu/3npv3e+lPqpql7h+gkT+DKWnhJ3sh2RPSs+TVqbbzQUzMygagFZf46VUARf itci46zWViLBVz//eEU2ux6x26vYmOrGRV5xNPrkXjvI7BtXa5lTCOUbCmaGsUH1JcSp XwFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 194-20020a6217cb000000b00575428b9ea7si3333077pfx.204.2022.11.28.19.07.15; Mon, 28 Nov 2022 19:07:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235304AbiK2DB4 (ORCPT + 83 others); Mon, 28 Nov 2022 22:01:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235290AbiK2DBy (ORCPT ); Mon, 28 Nov 2022 22:01:54 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C77445084; Mon, 28 Nov 2022 19:01:53 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NLnCs3z0Jz15Mxb; Tue, 29 Nov 2022 11:01:13 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 29 Nov 2022 11:01:51 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH v2 02/10] blk-throttle: Fix that bps of child could exceed bps limited in parent Date: Tue, 29 Nov 2022 11:01:39 +0800 Message-ID: <20221129030147.27400-3-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221129030147.27400-1-shikemeng@huawei.com> References: <20221129030147.27400-1-shikemeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Consider situation as following (on the default hierarchy): HDD | root (bps limit: 4k) | child (bps limit :8k) | fio bs=8k Rate of fio is supposed to be 4k, but result is 8k. Reason is as following: Size of single IO from fio is larger than bytes allowed in one throtl_slice in child, so IOs are always queued in child group first. When queued IOs in child are dispatched to parent group, BIO_BPS_THROTTLED is set and these IOs will not be limited by tg_within_bps_limit anymore. Fix this by only set BIO_BPS_THROTTLED when the bio traversed the entire tree. There patch has no influence on situation which is not on the default hierarchy as each group is a single root group without parent. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 59acfac87764..d516a37e82fb 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1067,7 +1067,6 @@ static void tg_dispatch_one_bio(struct throtl_grp *tg, bool rw) sq->nr_queued[rw]--; throtl_charge_bio(tg, bio); - bio_set_flag(bio, BIO_BPS_THROTTLED); /* * If our parent is another tg, we just need to transfer @bio to @@ -1080,6 +1079,7 @@ static void tg_dispatch_one_bio(struct throtl_grp *tg, bool rw) throtl_add_bio_tg(bio, &tg->qnode_on_parent[rw], parent_tg); start_parent_slice_with_credit(tg, parent_tg, rw); } else { + bio_set_flag(bio, BIO_BPS_THROTTLED); throtl_qnode_add_bio(bio, &tg->qnode_on_parent[rw], &parent_sq->queued[rw]); BUG_ON(tg->td->nr_queued[rw] <= 0); -- 2.30.0