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: 3180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1228091wrs; Sun, 16 Oct 2022 19:02:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ME43G8gD/wEEUBQE7h5sZI1PV/AadT6laSzEvQ59n8g5lV40fEqIZ3e0ZTiEJzHDHi0K1 X-Received: by 2002:a17:90a:db54:b0:209:e4e4:9344 with SMTP id u20-20020a17090adb5400b00209e4e49344mr30079776pjx.62.1665972138124; Sun, 16 Oct 2022 19:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665972138; cv=none; d=google.com; s=arc-20160816; b=bV/emf2MmRrvwzDQJDAYpAtOiQglTnV+6hRe32xG3GTOCDYDQxFGDhu4yKf35WBiBl oa/fAEn8A2VJ7otC77PwzP+eAOFu51ivkuEl2saQ+PwEj4C/hFV3s6d+Q+Eyg+uBsFIg hGysegAb2ryvCcknMFwUQxKNC/PLk+mAA+VvHvvuv8/bv9lvsUtHtFoTGqQJk6p5+XUt FMvWY6nZnD+rIQwpEl7HKobO7R46T3Zyr2SgQ3U6MVAm6sDCd+PkMrsyExmz79fg3G+R NYJHMQfk/UocDjXJIt+J32qeVUOk2LtoDAc4vnMIr+o7YhPgzSBCycFefclm65afJmwD Zafw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a630c04000000b0045f98453934si11020809pgl.872.2022.10.16.19.02.05; Sun, 16 Oct 2022 19:02:18 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746898401038679772?= X-GMAIL-MSGID: =?utf-8?q?1746898401038679772?= 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); /*