Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3817589rwi; Sun, 16 Oct 2022 19:16:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WPzT4CuMwhjuGSmkzNurRH7EpEOXiuJmotOpaoNqX+be+H1Y9uQOp0uJiDMFAr+x2UMIu X-Received: by 2002:a17:906:dac8:b0:741:545b:796a with SMTP id xi8-20020a170906dac800b00741545b796amr6803844ejb.240.1665973016090; Sun, 16 Oct 2022 19:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665973016; cv=none; d=google.com; s=arc-20160816; b=e0/12b97eV6/Al7Cvc60dBh3oYMGRaE4eD/cpCwyloJjtvff5ua8evq0PGSFwgy20k XcHFDIlsFquEzVeBoz6Ef3nZrceHN9mYsv05hPrIR+XM5p2/tbVM/tetDLa7WZl/reLF VyiLRm0K5jr72IgMs+7cg7oNT8pa66SI/6kiq393q4AjVuvnaHZLoXtJNYJnXkn8mMfz 1ovYaEpCRspqORu35H9Wx0cKSoDAI09lqCN6IOOPRwbweHRZjrwARCzv+y2/jB6WRKSl 1KGhqMSVcxBHGLMw5kObCH9JZsZTTJAys15r/lC+skRQGa0Yse342KFbN7VnbidcXnXL 4O/Q== 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=BuUH4PUGrcVcgAlB4+pi3JSy0vp+k73fNMXCgLyOUPQ=; b=bW62u62oFubK01RgeIm3xypkFDD8zLE2Z4O4TcXYiqicS9ob1Z+CuN+VkpYqtxugrX ygDM+YYuapzdI2K44G8adOq0NDuJTH3Q4zRo9rtY5V3nBujMC9liQKe/gg5O9KNKJVuI JEk0MhaLQ9uXYZlPn3R3hVwKDHQ6LbBJlA0aqBXP0UIDRSFZLWXwYbNx/6BS9+bMS6Wk wQbK78rLsZvYu4uU7NJGTu/CBI+ZMTAacIq4+F2Ct4aqHWxtmxmXfT47u6B8ksq/aklz 4ePco5Q0RKeh5VOtEWzkE/Rs9VO80tu01tGvNTsLbYQjhZ6Fzm/YLbQoFvj+ruq9FT6a sCYA== 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 e17-20020a17090658d100b007815e9c5b80si5079387ejs.617.2022.10.16.19.16.31; Sun, 16 Oct 2022 19:16:56 -0700 (PDT) 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 S230103AbiJQCAl (ORCPT + 99 others); Sun, 16 Oct 2022 22:00:41 -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 Content-Type: text/plain 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,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 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); /* -- 2.30.0