From patchwork Wed Nov 23 06:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2614617wrr; Tue, 22 Nov 2022 22:05:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5iaaBA4oyUWyga3SuZb3uWAJDfYJzsmyI3ZOEBXV/rtyM7JbV4t5HmjRDJBAaVkvXSVGQf X-Received: by 2002:a17:903:1c4:b0:186:5ef5:bda1 with SMTP id e4-20020a17090301c400b001865ef5bda1mr7258251plh.78.1669183516809; Tue, 22 Nov 2022 22:05:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183516; cv=none; d=google.com; s=arc-20160816; b=ecH5jMrAivUnkvdKG6oCavyz+SAKw6vTepQH3TSAIsxRUpuHREQ71Lop6wvFSZh5oQ OA3Nvkgw9jJ3GXUjXXi3qqgUaYRE3ll5uRtWOAZeoKJPEUNtyty3Rxf2WrUkozU8otJ6 cWUzDLEXxXtItw+rKEbxyEWeCZPaG/0jtOmkZ3Nezzc0VyucAEoHi/Qpu0cLPYj1G0Xe oSTsVfR8lZUneQycCHl5oKaMaqHzYcHMM96hZcIZjzpOYhga2UFsi+fTrTqOyJ7K++Qe ua0faJ8WfhZExBlY6ppMohze6zKY5FYeO3bQj0/K065CvR6aX4Od6Lka/hzDASY1FXeH 9ALw== 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=EQHANdk/M9WEOYUTzwJxac4ccziLf7UXV4NLqo80jZY=; b=BUDEBmuLNXBhFOj6Dl9wajPk2Im79BpDn37yKL7UNdzW0A5Gpl9U40mi++d/qVwuoE T4QPC9YDKZhsdD61Q74yiyWcttzLrgvaPet/DUpf9TbbsKiHWVsNlhRiJyWbI2mpRoft 00EuQ8tK5EWJCyYYogWqK1UM8ZxkpxvOrp+Bhdd2V28GphfW/f1bdjWfIEV6w/W1pRUf 2rb8uq/tPVPvukRufJbSpUzNXBxMT84YJF6SLKzBBey/jyjp0I+mv2dh1fP9eqlp24jZ GInVnYG+8FhNvv1p1l1XKgSdfLNEdA/fqQ8x4W666RBECvReDBflTMTB0BgN1XexC+kM J8GQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb11-20020a17090ae7cb00b0020a755f2b83si1066722pjb.100.2022.11.22.22.05.04; Tue, 22 Nov 2022 22:05:16 -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 S235606AbiKWGEf (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235611AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29833DB86F; Tue, 22 Nov 2022 22:04:07 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y15C6xzmW6g; Wed, 23 Nov 2022 14:03:33 +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; Wed, 23 Nov 2022 14:04:04 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 01/11] blk-throttle: Limit whole system if root group is configured when on the default hierarchy Date: Wed, 23 Nov 2022 14:03:51 +0800 Message-ID: <20221123060401.20392-2-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265775209069801?= X-GMAIL-MSGID: =?utf-8?q?1750265775209069801?= Quoted from comment in throtl_pd_init: "If on the default hierarchy, we switch to properly hierarchical behavior where limits on a given throtl_grp are applied to the whole subtree rather than just the group itself. e.g. If 16M read_bps limit is set on the root group, the whole system can' exceed 16M for the device." Commit b22c417c885ea9 ("blk-throttle: configure bps/iops limit for cgroup in low limit") broke this rule and did not explain why. Restore the ability to limit the whole system by root group. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 847721dc2b2b..96aa53e30e28 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -150,9 +150,6 @@ static uint64_t tg_bps_limit(struct throtl_grp *tg, int rw) struct throtl_data *td; uint64_t ret; - if (cgroup_subsys_on_dfl(io_cgrp_subsys) && !blkg->parent) - return U64_MAX; - td = tg->td; ret = tg->bps[rw][td->limit_index]; if (ret == 0 && td->limit_index == LIMIT_LOW) { @@ -180,9 +177,6 @@ static unsigned int tg_iops_limit(struct throtl_grp *tg, int rw) struct throtl_data *td; unsigned int ret; - if (cgroup_subsys_on_dfl(io_cgrp_subsys) && !blkg->parent) - return UINT_MAX; - td = tg->td; ret = tg->iops[rw][td->limit_index]; if (ret == 0 && tg->td->limit_index == LIMIT_LOW) { From patchwork Wed Nov 23 06:03:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2614524wrr; Tue, 22 Nov 2022 22:05:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf6EcloImk5KNdfDRy96PDd+EXnjH92Po33HkKsIinOm3ZNaUu62zG3vKblbrvut9cVtyQh1 X-Received: by 2002:a63:1111:0:b0:46f:f93b:ddc8 with SMTP id g17-20020a631111000000b0046ff93bddc8mr9598815pgl.389.1669183505486; Tue, 22 Nov 2022 22:05:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183505; cv=none; d=google.com; s=arc-20160816; b=KZLrPbnRjwJTGA9c8aipoUF22gBkA24S0+A3lLeG3hjgfoyITJxddottaJdC2dav0Z ne0tcP/VCly+JyPY03c5O8ngKB6oIkQjey6nNlN6V90y53aYORf/BmAUOz4JMRPptODA CVSjKqUcARWropfBDPwfS/G5PFFI1IV7QZm/ynSyMk0qe/wskLml13xm280Bc+PBFvSq IvK7kiHaLTU2MalyBCHs5CrsYNfW009OmPdq554uSY4UquQLnbfZHAd9Wl9d1zMT1T+Z 78BIfjBCBce0YHb3DBhm/Xt+U1msW878xvvRsz21l0CcrlLoBTjBnyuSq++w1gv8gX8w XQ+g== 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=PLG/6xOlzKuVWjSjCLfh02rt5akE/IGgFH/WCEl3xI4=; b=bTf/3fPW0urZG1Q7FnQWm22WfhP2eW+cPYK/Wirv5dmJMCoblUd4I6ADQ7/f087l6h 23egfpLqe2mzMB1hfnw/bK5nKxbmyFU7wbsLIDuWeBK+bqOho9Fo3SCHK/TU8rCm77d1 /BdhtkiqrzUzaGop4P6DFCxVj8snpW7koIEMDM0MCnYvU40aB9EdBOFfMBmrKdU4+wf7 OROAufu3S8TxG5ZbaD+HE5YOFLbWJsJ7iRsHJ/6TtCcJNZd6yDZzf1Yp1NQcLyL5zGWU ioUxXtZ4ENTuRseMvROrhOH+1/N0Mm93/8wGo/POl2/CFP1Gy9trnskh4l5Q/DmT38We 061Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a6546cf000000b00476f238d259si16690603pgr.420.2022.11.22.22.04.52; Tue, 22 Nov 2022 22:05:05 -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 S235875AbiKWGEX (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235548AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2994CF2C07; Tue, 22 Nov 2022 22:04:07 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y31DHdz15MqG; Wed, 23 Nov 2022 14:03:35 +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; Wed, 23 Nov 2022 14:04:05 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 02/11] blk-throttle: Fix that bps of child could exceed bps limited in parent Date: Wed, 23 Nov 2022 14:03:52 +0800 Message-ID: <20221123060401.20392-3-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265763899912392?= X-GMAIL-MSGID: =?utf-8?q?1750265763899912392?= 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: 1. Limit IO with BIO_BPS_THROTTLED flag in tg_within_bps_limit. 2. Ignore BIO_BPS_THROTTLED flag when accouting in throtl_charge_bio. There changes have 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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 96aa53e30e28..b33bcf53b36e 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -856,8 +856,7 @@ static bool tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; unsigned int bio_size = throtl_bio_data_size(bio); - /* no need to throttle if this bio's bytes have been accounted */ - if (bps_limit == U64_MAX || bio_flagged(bio, BIO_BPS_THROTTLED)) { + if (bps_limit == U64_MAX) { if (wait) *wait = 0; return true; @@ -964,10 +963,8 @@ static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio) unsigned int bio_size = throtl_bio_data_size(bio); /* Charge the bio to the group */ - if (!bio_flagged(bio, BIO_BPS_THROTTLED)) { - tg->bytes_disp[rw] += bio_size; - tg->last_bytes_disp[rw] += bio_size; - } + tg->bytes_disp[rw] += bio_size; + tg->last_bytes_disp[rw] += bio_size; tg->io_disp[rw]++; tg->last_io_disp[rw]++; From patchwork Wed Nov 23 06:03:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2614398wrr; Tue, 22 Nov 2022 22:04:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Xy8uLX/kFgKXaW2a2lQo4hX7GFbFMqA1EEVRe0XNVC+HYr2YkhVMm2OM5rrUJrAoS8xDr X-Received: by 2002:a17:90a:3f8e:b0:212:d644:fc20 with SMTP id m14-20020a17090a3f8e00b00212d644fc20mr29932270pjc.3.1669183486564; Tue, 22 Nov 2022 22:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183486; cv=none; d=google.com; s=arc-20160816; b=SJdMvQQhB8sb2INOYMgK4LLK8YHvQ6cCIpUenfGfRptE4nGCJ9GNf+1WhGDNr2mx4E 0Wm2BbyJEkOmN0G22y4j3MMupKR3fUqKTJAtDF7jGQIdSDkaagV6wgqrVxQmbMTV/tF0 lxXPxUJzRtVcmfo6PwBYw7wM1MDhLTsYPFxMx69AwAVthBoDP+NsM0HWo21+11nJWVY2 NQs3LKobGFxblHDJ2aS6MjG9pyjswMqzjx1eCYrMGGPefcz1fGYbmEHj4uV9DH+3mLaf Ar10UobJVsJ0Cfnewpm2SVtz0KCB5+R3zezEmG3zJMrAimGKTJfMswT6kvs3GgWRVn8s XT4g== 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=b+YlWhnNICoyt+4tL/pWEaMrlJo7McJUuiO5Tr9YiSI=; b=J0EkgIwG1J7LtAZ5my75RiNNC9Xrp6LBEzh6qBdeQqiQ0IrdK05q3V48epjkA/x8Yj iqo1SEaDyFn+D94CAMmBE+3JbvI6f4Vv8dQgT4rbix1Iuxs6mWxxJjA6bXBGOd3xJQjR AHWV+OJzFm/BSrPH0DZ4A6qPqtA1GXLDg4cqa7Z2j6g+MnHkdSwuUkLTnFTaBHwws3Sp LF3fxGWnLGy7wkw3WypbaPBDdeOSEa36+yfjllvARus8sA7v1GsNOCdSznxA55sTGk7v hepXPCkNGWKSUpLT9nfICJkICIaUn86/jvXskPBRa03XmOKKDQBRu8CMWrGicEB9ieqN GF+Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a170902dac700b00175449cf6f8si18046655plx.606.2022.11.22.22.04.33; Tue, 22 Nov 2022 22:04:46 -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 S235831AbiKWGES (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34396F2C08; Tue, 22 Nov 2022 22:04:08 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NH9Tt2rc6zJnrH; Wed, 23 Nov 2022 14:00:50 +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; Wed, 23 Nov 2022 14:04:05 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 03/11] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios Date: Wed, 23 Nov 2022 14:03:53 +0800 Message-ID: <20221123060401.20392-4-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265743503138464?= X-GMAIL-MSGID: =?utf-8?q?1750265743503138464?= Ignore cgroup without io queued in blk_throtl_cancel_bios for two reasons: 1. Save cpu cycle for trying to dispatch cgroup which is no io queued. 2. Avoid non-consistent state that cgroup is inserted to service queue without THROTL_TG_PENDING set as tg_update_disptime will unconditional re-insert cgroup to service queue. If we are on the default hierarchy, IO dispatched from child in tg_dispatch_one_bio will trigger inserting cgroup to service queue without erase first and ruin the tree. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index b33bcf53b36e..acfac916ed99 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1728,7 +1728,12 @@ void blk_throtl_cancel_bios(struct gendisk *disk) * Set the flag to make sure throtl_pending_timer_fn() won't * stop until all throttled bios are dispatched. */ - blkg_to_tg(blkg)->flags |= THROTL_TG_CANCELING; + tg->flags |= THROTL_TG_CANCELING; + + /* No need to dispatch cgroup without io queued */ + if (!(tg->flags & THROTL_TG_PENDING)) + continue; + /* * Update disptime after setting the above flag to make sure * throtl_select_dispatch() won't exit without dispatching. From patchwork Wed Nov 23 06:03:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2615097wrr; Tue, 22 Nov 2022 22:06:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Q4QAxQQk4lrRzzLgTpHM3JhlddXg9GWt704UyuzrLuJ0wAUmwJ6HITN5KmlqUQ9ISlZAM X-Received: by 2002:a05:6402:5406:b0:467:4b3d:f2ed with SMTP id ev6-20020a056402540600b004674b3df2edmr6995874edb.101.1669183593926; Tue, 22 Nov 2022 22:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183593; cv=none; d=google.com; s=arc-20160816; b=xxSspFkzy6UrA+BQwzgYJjtKkzxu6eBC7IiEK0P1dR+9uv0hjleb4+ay7v6rVFqke7 z/vLVvCve3ASs8NBW+j8Wnb7pbJ5/8Cc/fm1/xLgOvb1+ry+CJ2/aAyUgB+Yu67dCkbL k4VjKXdx8YxtV8sgEa/53FwCLA3qNId4Sh25R6T/YcRbb1q1jbOviw2ZBWgyV1usczbB M443qYUudhqtjpewWRUhZb5IeEcDi1gQjKG/CXyW2Pq7hu5kdGYttHYHIAz+8ja+tNBr vLNNY1XM34mDCUBC7R8i1ORaS+KYeddz1VQyUUgiTCQ2D6XS2WDfUrVsP3Exwmi4HY3b S78A== 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=LuNYhmntRZTZxnkACGsnMMx/rrTSAYrF0nWhXqx/94o=; b=vtFFf7qsjjhcqUAkiMwRYysZQU92oTQ/vGB7CUzu9NeZiRIP/TiWgSMSTP7D/aMinW jx5vGjSSEmquqULF0JIyMDhZ/wq/jQFRBvsiZPiGEI4w3eMn2dQB7oXDpApK1aCemvRz en2cGIA2Nb5gXO3Y6qs2gfbeGNfPhpX4heLZl/bMsXY5H9TWpp+nTrumQmjZY+dJmB13 wHOmbK1SJ3f5/2qIdiCHXr1aqNfs7o2H9lIN1me4bUdllfb/Gtdf1GFGeGGxzQPVYBm5 5pJgpyYU+xCLk20LJHBUyT7i/3s8s7aPZi1rTu9CspyOwqCCbWaSEA4l2UentH+ObNs0 CPnQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a0564021e9500b0045c3f6adb7csi15330329edf.215.2022.11.22.22.06.09; Tue, 22 Nov 2022 22:06:33 -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 S235909AbiKWGEj (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235620AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F3BB729A9; Tue, 22 Nov 2022 22:04:08 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NH9Tv0SYGzJnrQ; Wed, 23 Nov 2022 14:00:51 +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; Wed, 23 Nov 2022 14:04:06 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 04/11] blk-throttle: correct calculation of wait time in tg_may_dispatch Date: Wed, 23 Nov 2022 14:03:54 +0800 Message-ID: <20221123060401.20392-5-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265856102537435?= X-GMAIL-MSGID: =?utf-8?q?1750265856102537435?= If bps and iops both reach limit, we always return bps wait time as tg_within_iops_limit is after "tg_within_bps_limit(tg, bio, bps_limit) &&" and will not be called if tg_within_bps_limit return true. Fix this by always calling tg_within_bps_limit and tg_within_iops_limit to get wait time for both bps and iops. Observed that: 1. Wait time in tg_within_iops_limit/tg_within_bps_limit need always be stored as wait argument is always passed. 2. Stored wait time is zero if iops/bps is limited otherwise non-zero is stored. Simpfy tg_within_iops_limit/tg_within_bps_limit by removing wait argument and return wait time directly. Caller tg_may_dispatch checks if wait time is zero to find if iops/bps is limited. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index acfac916ed99..01e30380c19b 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -815,17 +815,15 @@ static void tg_update_carryover(struct throtl_grp *tg) tg->carryover_ios[READ], tg->carryover_ios[WRITE]); } -static bool tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio, - u32 iops_limit, unsigned long *wait) +static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio, + u32 iops_limit) { bool rw = bio_data_dir(bio); unsigned int io_allowed; unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; if (iops_limit == UINT_MAX) { - if (wait) - *wait = 0; - return true; + return 0; } jiffy_elapsed = jiffies - tg->slice_start[rw]; @@ -835,21 +833,16 @@ static bool tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio, io_allowed = calculate_io_allowed(iops_limit, jiffy_elapsed_rnd) + tg->carryover_ios[rw]; if (tg->io_disp[rw] + 1 <= io_allowed) { - if (wait) - *wait = 0; - return true; + return 0; } /* Calc approx time to dispatch */ jiffy_wait = jiffy_elapsed_rnd - jiffy_elapsed; - - if (wait) - *wait = jiffy_wait; - return false; + return jiffy_wait; } -static bool tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, - u64 bps_limit, unsigned long *wait) +static unsigned long tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, + u64 bps_limit) { bool rw = bio_data_dir(bio); u64 bytes_allowed, extra_bytes; @@ -857,9 +850,7 @@ static bool tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, unsigned int bio_size = throtl_bio_data_size(bio); if (bps_limit == U64_MAX) { - if (wait) - *wait = 0; - return true; + return 0; } jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw]; @@ -872,9 +863,7 @@ static bool tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, bytes_allowed = calculate_bytes_allowed(bps_limit, jiffy_elapsed_rnd) + tg->carryover_bytes[rw]; if (tg->bytes_disp[rw] + bio_size <= bytes_allowed) { - if (wait) - *wait = 0; - return true; + return 0; } /* Calc approx time to dispatch */ @@ -889,9 +878,7 @@ static bool tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, * up we did. Add that time also. */ jiffy_wait = jiffy_wait + (jiffy_elapsed_rnd - jiffy_elapsed); - if (wait) - *wait = jiffy_wait; - return false; + return jiffy_wait; } /* @@ -939,8 +926,9 @@ static bool tg_may_dispatch(struct throtl_grp *tg, struct bio *bio, jiffies + tg->td->throtl_slice); } - if (tg_within_bps_limit(tg, bio, bps_limit, &bps_wait) && - tg_within_iops_limit(tg, bio, iops_limit, &iops_wait)) { + bps_wait = tg_within_bps_limit(tg, bio, bps_limit); + iops_wait = tg_within_iops_limit(tg, bio, iops_limit); + if (bps_wait + iops_wait == 0) { if (wait) *wait = 0; return true; From patchwork Wed Nov 23 06:03:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2614571wrr; Tue, 22 Nov 2022 22:05:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mSPOp6tJ7/qYn6CW+2L00Lo5m+yFBRLp2y9qnMZAv3IXLfuYoliICnzNmr6jNby2oje0O X-Received: by 2002:a17:903:1314:b0:186:9b19:1dbb with SMTP id iy20-20020a170903131400b001869b191dbbmr18655691plb.59.1669183510799; Tue, 22 Nov 2022 22:05:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183510; cv=none; d=google.com; s=arc-20160816; b=GGlmiAg6BJYCyS0JrBjH/3AwQh74C51Zf4vqNnXzXMbl+zXCWBiMa3kcDtmeqfN4o2 e/nuzHHKvik39e15WyX1G5tIOmBo6XrUlkHuiikwmMfhX2XuO/GDsvyM/ipckSGQpp/u 4LzDISfE1suMzbriIItPra+f+qLH3CJ4M/wcm71En1g8PUFg8b53N6IP3RchWexWpM7Z FOgrdB5HFvj2UL0pyclpHlwWUmGPQJa6L2Tqe+P8U50xitQcmGQznqA75Y/JaXkjc2Zq 0S8GCqIeGIEcPB12jnZWLumi1Oi8XsCeGmEUTMznD2dCb/F7TNxRav0gVa43U8FxSPHn ruwg== 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=unf+8vEd0DuM8K5XbysTkw1WQY21NqzNwh8U1+3iEno=; b=lQnAufTKCzR4yzBFJqMJhDZGLvCQLbE6BhH2hBBbooL8fmaQMOSgFPWq1X8HHX253b 2JpPpcvAqsHpaDVOjSloB909dDK/iVGX+B+Tkr4wbDUaiQZhlC88tKwfNe+pSpOQ7qOv FjZDgzkceMkwgwkkYGmIbBwf0LjB3d9pVum/Tgig2CMQMeaxFgbGddFg4gBY1e+bDJlN xeTcMqxxqXvBBQQ4Ae3xhbOF5vRtfxGuBC0E9DKSwP6r9AHwnXw2UghZx8+OEq+ZmfGO 4l3Rc2MqWRi8W+NqVk8PIBVn+FI8eBB3aA7W0Jm5NsPyC9gdV6zfTmXRLGDo6qpVA6kM XXcw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jk12-20020a170903330c00b001893740c58asi2503163plb.393.2022.11.22.22.04.56; Tue, 22 Nov 2022 22:05:10 -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 S235882AbiKWGE1 (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42123F2C09; Tue, 22 Nov 2022 22:04:09 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NH9Tv4b8SzJnrS; Wed, 23 Nov 2022 14:00:51 +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; Wed, 23 Nov 2022 14:04:06 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 05/11] blk-throttle: simpfy low limit reached check in throtl_tg_can_upgrade Date: Wed, 23 Nov 2022 14:03:55 +0800 Message-ID: <20221123060401.20392-6-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265768815393681?= X-GMAIL-MSGID: =?utf-8?q?1750265768815393681?= Cgroup reaches low limit if limit is zero or io is already queued. Cgroup will pass upgrade check if low limits of READ and WRITE are both reached. Simpfy the check code described above to removce repeat check and improve readability. There is no functional change. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 01e30380c19b..322a6ee38fb6 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1800,24 +1800,22 @@ static bool throtl_tg_is_idle(struct throtl_grp *tg) return ret; } -static bool throtl_tg_can_upgrade(struct throtl_grp *tg) +static bool throtl_tg_reach_low_limit(struct throtl_grp *tg, int rw) { struct throtl_service_queue *sq = &tg->service_queue; - bool read_limit, write_limit; + bool limit = tg->bps[rw][LIMIT_LOW] || tg->iops[rw][LIMIT_LOW]; /* * if cgroup reaches low limit (if low limit is 0, the cgroup always * reaches), it's ok to upgrade to next limit */ - read_limit = tg->bps[READ][LIMIT_LOW] || tg->iops[READ][LIMIT_LOW]; - write_limit = tg->bps[WRITE][LIMIT_LOW] || tg->iops[WRITE][LIMIT_LOW]; - if (!read_limit && !write_limit) - return true; - if (read_limit && sq->nr_queued[READ] && - (!write_limit || sq->nr_queued[WRITE])) - return true; - if (write_limit && sq->nr_queued[WRITE] && - (!read_limit || sq->nr_queued[READ])) + return !limit || sq->nr_queued[rw]. +} + +static bool throtl_tg_can_upgrade(struct throtl_grp *tg) +{ + if (throtl_tg_reach_low_limit(tg, READ) && + throtl_tg_reach_low_limit(tg, WRITE)) return true; if (time_after_eq(jiffies, From patchwork Wed Nov 23 06:03:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2614583wrr; Tue, 22 Nov 2022 22:05:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5IxmplFsta4HkTDdh6D81KiV7vdDv6fyB5P5HdYUPr2oXd5R6D8BjjpXhgbBzr1+pwMxjP X-Received: by 2002:a17:902:d40a:b0:189:1890:77df with SMTP id b10-20020a170902d40a00b00189189077dfmr7708308ple.132.1669183513208; Tue, 22 Nov 2022 22:05:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183513; cv=none; d=google.com; s=arc-20160816; b=wrBt6ve6guWMFDfJgKfjJqAU369gRXInE3fvPQ5CsnauAstmHk0RNsvraZgAChi/sx FxZh+4CNMZMtEDADcjHuBl3qBKjhZ+XsKPLEm1f6Pe8C5uY8miPAjmgALyZPQObYb90h 6TEmaT04fDS/P0o/Kr2d/dJ093JpWLzHq4C8RfDELBseKG+qRIQ+rDM3U6Ga1BR1ghBf Nm+t3yHxloRMY8CgygWN7EeX7234YPihqfIUc+SYCPat6Isa6ObiMGVxkFGioD5tGYe0 vxmoZ2y7B6I7AhbNKId3LMrp10exYC5q4ApXpWJmre6AOODIVK86RYoc9QadHuMSF/I6 ulMA== 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=JVr24QinAz6d63U3nVb56T217eys6AyH859kJk+MdqE=; b=lc83uDs5YLeQrkTHXVymRwwwlN7pLxVZj84HJhUPMlfTzLwBvbP3ZT0PALYpyy9m6J PI1voO3aTfe+bl8Lezy0LvjFGtd4vNDmi2diCEVoi+EipcLt8/rOBjDtdnAc3NxP92RC fxKt3/lc2dQ660UFoeke9H22m7ydzwH/encCBiYLFKsTotc3tQX2Xdw0J3vFqpcSn7XN xzPqqQqiOkk94fxdACsCk0Gy2qAmD4xAjGMnhXT0a8kRDL9f61tbX2e5s/kLnfJllCZo bGYSRWGdwcvzp8Ypu5wp6gxHo/NOB9tagGRBPuDZnad+v2gfCJiIszb/SLd9o/t19BsJ kCCQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a17090311c800b00176ab3bdffdsi17862195plh.536.2022.11.22.22.05.00; Tue, 22 Nov 2022 22:05:13 -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 S235892AbiKWGEb (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235612AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEECEF2C0A; Tue, 22 Nov 2022 22:04:09 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y54pTXz15Mq3; Wed, 23 Nov 2022 14:03:37 +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; Wed, 23 Nov 2022 14:04:07 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 06/11] blk-throttle: fix typo in comment of throtl_adjusted_limit Date: Wed, 23 Nov 2022 14:03:56 +0800 Message-ID: <20221123060401.20392-7-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265771835004745?= X-GMAIL-MSGID: =?utf-8?q?1750265771835004745?= lapsed time -> elapsed time Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- 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 322a6ee38fb6..0aa21832cb96 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -129,7 +129,7 @@ static struct throtl_data *sq_to_td(struct throtl_service_queue *sq) /* * cgroup's limit in LIMIT_MAX is scaled if low limit is set. This scale is to * make the IO dispatch more smooth. - * Scale up: linearly scale up according to lapsed time since upgrade. For + * Scale up: linearly scale up according to elapsed time since upgrade. For * every throtl_slice, the limit scales up 1/2 .low limit till the * limit hits .max limit * Scale down: exponentially scale down if a cgroup doesn't hit its .low limit From patchwork Wed Nov 23 06:03:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2617417wrr; Tue, 22 Nov 2022 22:13:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6XCgHhnmlJYXNSIo/SwgnIJVfFj61KsheiYVBmIbjzE+fZuuNRl51w6m3HAvUx6ipwCHse X-Received: by 2002:a17:906:1682:b0:78d:6ba1:74dd with SMTP id s2-20020a170906168200b0078d6ba174ddmr23439603ejd.119.1669184026771; Tue, 22 Nov 2022 22:13:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669184026; cv=none; d=google.com; s=arc-20160816; b=ALM0Q1k/367hzULb+sgaEP8T2k2Ly6yGiC9QCkWfyNn2D8NW3QE8GDBuf+/1BwivEN 0AvvgHy9NS7wfIhspUzIyesVtF99XGJXhUIi1b+LydxDL0GilvJxsTh1SN6g7n4YP7+d jyr3z/6eI4vgWuJyhbBMLh9OW1ct70MNVwb/VGtuEQ+BOdh2Eik2iEXkjWzmVJ6V1aFF OBo7NNmeC47v1n83USCnyjKVvqPD9hJKYloaBCs3ZWJEZuczN0QUrbme62KJ7iP0Yn3y HFG/ShGLbOJ1Gx2RC+Q12qL/rCLXL7eWGmzaHyhVqSiuXMAGPo8OUqYvw76dDXRxTkTQ lQPg== 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=Tbs+45x2l07CRaAe8zsFdTxHzDuaUUWGgMr4VDYrD8A=; b=Ml3HeULHNYNdiMpJrzNgu+ZrA3zMTTH5lDh1NftAMuoH2b2Pm4RCBLURNCtcwd23Vk lsbTDkQOGONbqiubR2DTYDe+4/3NRCN0wMY5bSZsOll8tnMOf2t8o3099C+gERtI4iMH wJRizhsMQeJX6Xwkz7kTdGrK60XXFn4hgqzR/xs0G+VFhIVGDaO7UeI3xJ+dXEEZrnpW HQaPm9B0UZ5iIU4Xm4zPQohEtYds6uKdBnxofQMA4WUFpeGawm7M2TUQddXZTLG1KfVq vsLUHlllD1jvfNizeO7ELPCs9Gyd6IzZIjYLZnCN23ccNgzwkjN+uf7tcBn0ceTjaFsK 929A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i15-20020a056402054f00b0046a085157f3si1648365edx.313.2022.11.22.22.13.22; Tue, 22 Nov 2022 22:13:46 -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 S235917AbiKWGEm (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235644AbiKWGEL (ORCPT ); Wed, 23 Nov 2022 01:04:11 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A68F2C05; Tue, 22 Nov 2022 22:04:11 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y101kYzHw2C; Wed, 23 Nov 2022 14:03:32 +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; Wed, 23 Nov 2022 14:04:08 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 07/11] blk-throttle: remove incorrect comment for tg_last_low_overflow_time Date: Wed, 23 Nov 2022 14:03:57 +0800 Message-ID: <20221123060401.20392-8-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750266310129708403?= X-GMAIL-MSGID: =?utf-8?q?1750266310129708403?= Function tg_last_low_overflow_time is called with intermediate node as following: throtl_hierarchy_can_downgrade throtl_tg_can_downgrade tg_last_low_overflow_time throtl_hierarchy_can_upgrade throtl_tg_can_upgrade tg_last_low_overflow_time throtl_hierarchy_can_downgrade/throtl_hierarchy_can_upgrade will traverse from leaf node to sub-root node and pass traversed intermediate node to tg_last_low_overflow_time. No such limit could be found from context and implementation of tg_last_low_overflow_time, so remove this limit in comment. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-throttle.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 0aa21832cb96..bd07f562c799 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1746,7 +1746,6 @@ static unsigned long __tg_last_low_overflow_time(struct throtl_grp *tg) return min(rtime, wtime); } -/* tg should not be an intermediate node */ static unsigned long tg_last_low_overflow_time(struct throtl_grp *tg) { struct throtl_service_queue *parent_sq; From patchwork Wed Nov 23 06:03:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2617696wrr; Tue, 22 Nov 2022 22:14:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Eam0ZY0ECbPutXUpfTDZtcIcA3pvb3hNL4dpFqucpseyYer71Q/qz+c7XKMDa3fykPTKP X-Received: by 2002:a63:fa45:0:b0:476:e63a:99b6 with SMTP id g5-20020a63fa45000000b00476e63a99b6mr9755595pgk.60.1669184089673; Tue, 22 Nov 2022 22:14:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669184089; cv=none; d=google.com; s=arc-20160816; b=i0jxsbJ7XRgsaZwRUNNTf/xyizJaYut71PffGd8Svx45oD6rJ6JjqKYMLfNV3jhAkM 61oqobI5TVgUobyeVWHPmaM47EPY0VRwIsnvkCbwRTf34xxq97juJlNTDuoky/o77cqJ QHhOR15dQQN4ZS8rcUsiZ8NtEPtEuJzby6TR6qQt3993LIkasIXsJWLIYaTSuNQU51i3 pagiCmWwU5OXVFT9qhPQkXcO/Yx8TtysxVS6DxYaEQUqZc8HEW06IlVqeKwA7qnmVHDr NGNMXv1a4M3SDulSWY/7iG+ko5g8hgRL1lMCkJheduVjZ66YqF/BcpPwpZQncVa9Vsph CKAQ== 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=KOpk+qo/jiL3mD9ORxM3SXeURwL2x7Dis2yse1MWqnk=; b=DGP+8C5jKLadHb/JDzo1QmfRg/ucEJPL8rP4v6Ij4gczqE1ZP5eimLvw7KWSHk8eAL GtvFh1x+eo8jMPV3OJVqBbkVZ0Ca0P9vG8ZaLqgdua4mba6dmRjqm1ABpA/BKlwy007w /XmqOS2ck+86G9lUMr3P5vIDcKIZpVolsXXrgCl1vHdPG3oORnu3KbaaNwBAHohwMohJ 7taAEDmDFq28MLNfx/4bSP/J9ZDjm1yK4psD50sMEBAtUmHwWiXkLn5YXXMsBfHAEgfY cJrFOfPhBlX64sFUe81c9ipt8RdpnNEBjb3mWciTslK9NFhgkdSaf2eYvxzWBIp/T6aA flMQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a6553c2000000b0047787372364si5810311pgr.363.2022.11.22.22.14.36; Tue, 22 Nov 2022 22:14:49 -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 S235911AbiKWGEs (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235751AbiKWGEM (ORCPT ); Wed, 23 Nov 2022 01:04:12 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 468FE729A9; Tue, 22 Nov 2022 22:04:12 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y669zwzmW7F; Wed, 23 Nov 2022 14:03:38 +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; Wed, 23 Nov 2022 14:04:09 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 08/11] blk-throttle: remove repeat check of elapsed time from last upgrade in throtl_hierarchy_can_downgrade Date: Wed, 23 Nov 2022 14:03:58 +0800 Message-ID: <20221123060401.20392-9-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750266376000642468?= X-GMAIL-MSGID: =?utf-8?q?1750266376000642468?= There is no need to check elapsed time from last upgrade for each node in hierarchy. Move this check before traversing as throtl_can_upgrade do to remove repeat check. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index bd07f562c799..3eccc7af4368 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1932,8 +1932,7 @@ static bool throtl_tg_can_downgrade(struct throtl_grp *tg) * If cgroup is below low limit, consider downgrade and throttle other * cgroups */ - if (time_after_eq(now, td->low_upgrade_time + td->throtl_slice) && - time_after_eq(now, tg_last_low_overflow_time(tg) + + if (time_after_eq(now, tg_last_low_overflow_time(tg) + td->throtl_slice) && (!throtl_tg_is_idle(tg) || !list_empty(&tg_to_blkg(tg)->blkcg->css.children))) @@ -1943,6 +1942,9 @@ static bool throtl_tg_can_downgrade(struct throtl_grp *tg) static bool throtl_hierarchy_can_downgrade(struct throtl_grp *tg) { + if (time_before(now, tg->td->low_upgrade_time + td->throtl_slice)) + return false; + while (true) { if (!throtl_tg_can_downgrade(tg)) return false; From patchwork Wed Nov 23 06:03:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2617410wrr; Tue, 22 Nov 2022 22:13:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4tOSiK0yy6UawSuGZcxihgkR9DYSyktO7ey/IYBKvAHP+2c2cqSfIhpD358mgRI17M6n09 X-Received: by 2002:a17:90b:3444:b0:214:e1:cabe with SMTP id lj4-20020a17090b344400b0021400e1cabemr7182740pjb.153.1669184024998; Tue, 22 Nov 2022 22:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669184024; cv=none; d=google.com; s=arc-20160816; b=JLLzZR0y1WXwjQSR8lNvg5P6e9qJkRavQBJEr8J7O0Wm/H5/+pRAdumazWX5HYBVTO kB1bDMfRASiRBzCW10VC82gcGzo+4kgbDBEiGRZZM0HWbZKv5IujWfvMZGuAD6m1gEsp xzDAdL53jjkXyBaXwCEQrjD7Rhd4WVSIUVPsgZ6GFIehDiDdv9CurKfO49gjCl8zP6Rr qTieqwGDvzvhJ3sJIn9zZCnqu6Q3agILoHRjg6aadHzlnZk/eyN+ZBPjy9txfIsOs6YI fido/KjJMI+Pf64IAClDeAIrFSEsTdHVQCBk/AQ5ZnQAdfL6BOWax86RKCT3s/sSrKp0 2EgA== 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=3a2RkVfiDxYzQmdktFA6615MgVSMHHm+hBhNcYIQhx0=; b=O/ZcTJ0NqwJ163cO9EE/gQ1Ma02u2dlTu7N+azHlGzf4Fn5yjNJx20HkZL10yHVtkF /JPIFiRJhTPw5hNM/knhw5QM0qFfhRlZuVRKx9F9p86y8Uhro7JF0TyHTmBB/V4X5VsO YFZKnhCdXJx/owcoybzi/O1OK+mhkaaxL0JRV1Z18HpTOqknx3XlCjPrHlzNpcK+a9gr bk67EzM1hNXHukgfe1SwfW1E52A5/SA11bb4QPhUKF0OrETbond8VmpNr2cAjuItY2ec gizOxp7G1WuQJ5C9gIM61ifCuLm5bLbM8t6fbEYPyZVe1iE+/bbxre2k7LY984IRIjNC FQmQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170903234d00b0016da027a727si17553789plh.116.2022.11.22.22.13.31; Tue, 22 Nov 2022 22:13:44 -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 S235941AbiKWGEy (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235777AbiKWGEN (ORCPT ); Wed, 23 Nov 2022 01:04:13 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE56F2C0A; Tue, 22 Nov 2022 22:04:12 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y73f6LzmW7J; Wed, 23 Nov 2022 14:03:39 +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; Wed, 23 Nov 2022 14:04:10 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 09/11] blk-throttle: remove unnecessary check for validation of limit index Date: Wed, 23 Nov 2022 14:03:59 +0800 Message-ID: <20221123060401.20392-10-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750266308286906706?= X-GMAIL-MSGID: =?utf-8?q?1750266308286906706?= We always keep limit index valid as following: Max limit is always valid and low limit can only be invalidated in blk_throtl_update_limit_valid. Each time low limit may become invalid after blk_throtl_update_limit_valid is called, we will check and make sure current limit index is valid. It's reasonable to always keep limit index valid, so we can remove this check. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 3eccc7af4368..6f509cadd92b 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -418,12 +418,10 @@ static void tg_update_has_rules(struct throtl_grp *tg) for (rw = READ; rw <= WRITE; rw++) { tg->has_rules_iops[rw] = (parent_tg && parent_tg->has_rules_iops[rw]) || - (td->limit_valid[td->limit_index] && - tg_iops_limit(tg, rw) != UINT_MAX); + (tg_iops_limit(tg, rw) != UINT_MAX); tg->has_rules_bps[rw] = (parent_tg && parent_tg->has_rules_bps[rw]) || - (td->limit_valid[td->limit_index] && - (tg_bps_limit(tg, rw) != U64_MAX)); + (tg_bps_limit(tg, rw) != U64_MAX); } } From patchwork Wed Nov 23 06:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2616203wrr; Tue, 22 Nov 2022 22:09:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4pB7H7BgHp8jXG0PyZtVeIPce/AO+jopnVwObHq61Nl+Md0nzE+o7r8zQuUYJSjJ+Sq/Xs X-Received: by 2002:a17:907:d042:b0:78c:c893:1965 with SMTP id vb2-20020a170907d04200b0078cc8931965mr21620180ejc.247.1669183780893; Tue, 22 Nov 2022 22:09:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183780; cv=none; d=google.com; s=arc-20160816; b=idynxgI73v7WapwaUAFrTOAosn9csLm3Pqsk1yWJjzOOze7kwvhHzVUQbhDdZuilzK 5a2eIpdIoIOGh8R3cuJrVPJF3SLXRM1LOJwtwPWf73v8snc+2LM0s5o5cKVGDeZ684hB zI37f+BjbUlAQQ359qIK7Xpd/54toMpdvBIGsxaWoVXa63UVgABResqhXOm3mya/XqA5 Fjvxdi7HxEi2vJjYIW7sKpQr0Rj1JvcS/1T/nRKyZ2y9L2c6VOfyhKNLGUB3uD3DvE3+ gnLj8xeORxWZC9lJLLZlo65ddkiITa4VPuCM2qQ9xGAwsZMx0zY1XygQx5mcCKQtW6CM z/KQ== 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=q+nG8Jr6OQf+axS9Hwt5SFNf0VOb9qHj1BIgow/54Ek=; b=NbMb1IRLt0PyIi9dT7zMQxPmlxegkF7+aB2N3kBv09gHJeRP6cGmNYHDuzeskvEZWg nITN1/4fau5iI2rTjwaGrKzXmHtzRh2lNaExF4LC6tgtcuuE2r5i4O8UZIYiKDY6sVKM Gn3HgURgX7Y2QY1Zs4H92y1fOy3MWYUZpVNM8NXr775fMKDL3nFpE8XTezEnuCdha52V WJ95UQhCnAaR/O7UjfYCjIZnH0cXld8cr/KvkZi/OVls5HI1j0mZuKOJ2GpqDp9fzCJ3 fEnJgriKSQCKXDr0tBrsng/n7DS5Rmw7EijaDYj23bYKeacU4EcEpj6hjew+L6BsPA+f Ab2Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a05640217c600b004697dff9639si6982767edy.327.2022.11.22.22.09.15; Tue, 22 Nov 2022 22:09:40 -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 S235946AbiKWGE6 (ORCPT + 99 others); Wed, 23 Nov 2022 01:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235781AbiKWGEN (ORCPT ); Wed, 23 Nov 2022 01:04:13 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116EFF2C05; Tue, 22 Nov 2022 22:04:13 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NH9Y26TlDzHw2Z; Wed, 23 Nov 2022 14:03:34 +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; Wed, 23 Nov 2022 14:04:10 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 10/11] blk-throttle: remove unused variable td in tg_update_has_rules Date: Wed, 23 Nov 2022 14:04:00 +0800 Message-ID: <20221123060401.20392-11-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750266052409633668?= X-GMAIL-MSGID: =?utf-8?q?1750266052409633668?= remove unused variable td in tg_update_has_rules Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 6f509cadd92b..82fe23e79b4b 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -412,7 +412,6 @@ static void throtl_pd_init(struct blkg_policy_data *pd) static void tg_update_has_rules(struct throtl_grp *tg) { struct throtl_grp *parent_tg = sq_to_tg(tg->service_queue.parent_sq); - struct throtl_data *td = tg->td; int rw; for (rw = READ; rw <= WRITE; rw++) { From patchwork Wed Nov 23 06:04:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 24723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2617740wrr; Tue, 22 Nov 2022 22:14:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5uvKGmb79jTsK6y7FHtGHpnJC5Gkz432PMUJlc2gSHCwNnocRg0/j7CZ4Xws88DssR9Zrj X-Received: by 2002:a17:90b:2686:b0:218:bb0a:e295 with SMTP id pl6-20020a17090b268600b00218bb0ae295mr12040289pjb.80.1669184098134; Tue, 22 Nov 2022 22:14:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669184098; cv=none; d=google.com; s=arc-20160816; b=INH317m00ZnoYNM3ccxa8riyUrqZI9CGs0TAXK5Gt81wpL9SA0EqfNKpE+vJn6DOFG kVfHSfpkrK+eX/JSnuz496r6TcfUSAHfxGEtGWtx4TyoLfFEJc1bTHoy6aEETK9spEw2 e8KhssSx0BikGgmqlfDPrrM2rEnAEVDUqvob32ZXLjOz77Vbjs1gj/IadTrW1Zo9sBgg ePosNjhrU5x74z4BiAgYjS38ZCVmNmUp8fTyzIbktfTZkXCtxf7HoAZAk7LUcBnmV6x0 esskeqW+X67HDzCbQIFOQy+jps8OKwPC88BH0dgRQozzgVBv7HtNnrpk6VdIFzcVV1UJ YYgg== 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=vT2669sm5EtsWOgJ8OCjJb4lopW/XJq9uxtQAO/1ajI=; b=PVERjDMAthvzgK2g4hve1A/7+ekZmPW36cKIs0U6r6W3aPhv9vIKBGukDPEFUbKbKb cnnC/sJpbUIYad6s7ZC414tY2c2axG2Aw0JYvGwxcyfI9KCVjRDD4ot9FULv9iU2uPsL xY8hKR0CrPgx9JIDffGX5HF6Z7nYUEhILi7T2/Py8nBffwjcTjGWgn0tbR1k770eedur OU0HBxfSN0yGT4aDSXvcKudyoUt2AWxymTPwUqfSIEA/XOZvXecUT1pYV7EK4qWjzATN Tnrr1sH2fcPU1e1pLYCN9Jg2MFtkYRN1AsktwmoIHAX6TalCdsbEjkKBwMufkOOiaj1O kFdA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r134-20020a632b8c000000b0047063e59929si16042830pgr.836.2022.11.22.22.14.45; Tue, 22 Nov 2022 22:14:58 -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 S235951AbiKWGFC (ORCPT + 99 others); Wed, 23 Nov 2022 01:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235810AbiKWGEP (ORCPT ); Wed, 23 Nov 2022 01:04:15 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5337729A9; Tue, 22 Nov 2022 22:04:13 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NH9V014sDzJnqw; Wed, 23 Nov 2022 14:00:56 +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; Wed, 23 Nov 2022 14:04:11 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 11/11] blk-throttle: Use more siutable time_after check for update slice_start Date: Wed, 23 Nov 2022 14:04:01 +0800 Message-ID: <20221123060401.20392-12-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750266384635299564?= X-GMAIL-MSGID: =?utf-8?q?1750266384635299564?= Use more siutable time_after check for update slice_start 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 82fe23e79b4b..69eeff764dee 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -635,7 +635,7 @@ static inline void throtl_start_new_slice_with_credit(struct throtl_grp *tg, * that bandwidth. Do try to make use of that bandwidth while giving * credit. */ - if (time_after_eq(start, tg->slice_start[rw])) + if (time_after(start, tg->slice_start[rw])) tg->slice_start[rw] = start; tg->slice_end[rw] = jiffies + tg->td->throtl_slice;