From patchwork Mon Oct 17 02:00:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD6CFC43217 for ; Mon, 17 Oct 2022 02:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbiJQCAX (ORCPT ); Sun, 16 Oct 2022 22:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbiJQCAU (ORCPT ); Sun, 16 Oct 2022 22:00:20 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36B5237C0; Sun, 16 Oct 2022 19:00:19 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MrKrP1ZrhzJnV4; Mon, 17 Oct 2022 09:57:41 +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; Mon, 17 Oct 2022 10:00:17 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 6/8] blk-iocost: Avoid to call current_hweight_max if iocg->inuse == iocg->active Date: Mon, 17 Oct 2022 10:00:09 +0800 Message-ID: <20221017020011.25016-7-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221017020011.25016-1-shikemeng@huawei.com> References: <20221017020011.25016-1-shikemeng@huawei.com> MIME-Version: 1.0 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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The old_hwi is already max hweight_inuse if iocg->inuse == iocg->active. Remove unnecessary calculation. Signed-off-by: Kemeng Shi --- block/blk-iocost.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 96c1571a8a1d..fa90f471dfdc 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2299,7 +2299,10 @@ static void ioc_timer_fn(struct timer_list *timer) * Determine the donation amount. */ current_hweight(iocg, &hwa, &old_hwi); - hwm = current_hweight_max(iocg); + if (iocg->inuse == iocg->active) + hwm = old_hwi; + else + hwm = current_hweight_max(iocg); new_hwi = hweight_after_donation(iocg, old_hwi, hwm, usage, &now); /*