Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8805347rwb; Thu, 24 Nov 2022 04:39:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf48M1wRtY8xQAQGeeoRg9x7xuVUxkvY+zTeq1NRZYiuwrJIpaXz/EGWaVS1I+mRvrbEdIJ0 X-Received: by 2002:a63:24c5:0:b0:477:dbc9:2122 with SMTP id k188-20020a6324c5000000b00477dbc92122mr24655pgk.290.1669293582541; Thu, 24 Nov 2022 04:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669293582; cv=none; d=google.com; s=arc-20160816; b=ewsN6VTFRajfywOWgIMdnE8F7zHI0dlGAhKgERuEJsudZwePTn1lDs/N/Ba1rb9XPz MbmQpaQDxEy27fpDCBXLTsNcFB0bNqgIpBL7gwEKGAhA4tZorwlVYRIv91NwX2QmnIgv 5Sn1YRVk4WsPho7nbUbIfrSKrltWiXxyssk50XmDI9kaq/q+MMdmgE/s3rJn8XTziWij RQGRPJRG8hqZ7TpXSqq8of2nDTt43csIpxQ3qqwLWmdKtPO6ib/ZkO+CUlMe6bp9LcjQ 5CDLs2+lEFxMe16M0zbCjyHO6X3qu7yEhbMRlHXZsfrg+rPXJ4XXbTuA4ni+vcOn2K8+ /g7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=FixuSexSdaSqpEX8pHylJe0/BWgKvLUSnIufRXqsAj4=; b=t/0Z+3ugeOlk1gTIL8ijUB0Kl10+CcNPT3/t9Lqo5o1isbvV3Ja+H6XIuGOm44FAHp +8bQ6TSSyx0/4wNjLjlCGNLy/rHh9rn+PnKzTk5g1BM9VluhtaEyxybLQ8PIKdxKGsKu 8sivdRRlSHrdXvip5yR+dg09IK16z2wH4le+I2YnU9U2FaO0cB9702h1x2HlxaRFX5bu TQ0WFGHXBT/l28TODdjYs+tu86tB0q9gm6pnuCLQBPvdnLFxf3I+LnUgHI78BdUV2H4j TeCTIOZajJ28YPJDFBOFAC1aS17g9F6gfInhU4OxtwzvpCA+MhcJhce2YjtdBa65IPyU QNBQ== 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 q10-20020a170902edca00b0018725be1285si840101plk.558.2022.11.24.04.39.31; Thu, 24 Nov 2022 04:39:42 -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 S229589AbiKXMKI (ORCPT + 86 others); Thu, 24 Nov 2022 07:10:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbiKXMKI (ORCPT ); Thu, 24 Nov 2022 07:10:08 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3890A742C5; Thu, 24 Nov 2022 04:10:07 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NHxXx0Kw5zqSdh; Thu, 24 Nov 2022 20:06:09 +0800 (CST) Received: from [10.174.178.129] (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; Thu, 24 Nov 2022 20:10:04 +0800 Subject: Re: [PATCH 04/11] blk-throttle: correct calculation of wait time in tg_may_dispatch To: Tejun Heo CC: , , , , References: <20221123060401.20392-1-shikemeng@huawei.com> <20221123060401.20392-5-shikemeng@huawei.com> From: Kemeng Shi Message-ID: Date: Thu, 24 Nov 2022 20:10:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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,NICE_REPLY_A, 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 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on 11/24/2022 2:18 AM, Tejun Heo wrote: > On Wed, Nov 23, 2022 at 02:03:54PM +0800, Kemeng Shi wrote: >> 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. Here is a mistake, the right word should be: 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 *false*. > Maybe it's obvious but it'd be better to explain "why" this change is being > made. In C language, When executing "if (expression1 && expression2)" and expression1 return false, the expression2 may not be executed. For "tg_within_bps_limit(tg, bio, bps_limit, &bps_wait) && tg_within_iops_limit(tg, bio, iops_limit, &iops_wait))", if bps is limited, tg_within_bps_limit will return false and tg_within_iops_limit will not be called. So even bps and iops are both limited, iops_wait will not be calculated and is zero here. So wait time of bps is always returned. >> @@ -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; > > So, max_wait is supposed to be maximum in the whole traversal path in the > tree, not just the max value in this tg, so after this, the code should be > changed to sth like the following, right? > > max_wait = max(max, max(bps_wait, iops_wait)); > > Thanks. > -- Best wishes Kemeng Shi