Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp181179iol; Thu, 9 Jun 2022 01:23:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsq9LG4B48ebbufK9AemudJIPbxznK+QuHhVZOwyaBuZQAk74bBXZaP51SR2PPPtjWxviY X-Received: by 2002:a17:907:1b14:b0:6ef:a5c8:afbd with SMTP id mp20-20020a1709071b1400b006efa5c8afbdmr35035747ejc.151.1654762997498; Thu, 09 Jun 2022 01:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654762997; cv=none; d=google.com; s=arc-20160816; b=ynxIphw1LtGPo5oN5CvGeaY/3OtO91f3GuThw6Hz03+UBMPKHHpj6yCymWAncNHt5i yiFQs2y7jAQHqWWov93MyggiaR21fAWLPBJhiyNd5i4Krr5hiwO1hWhpWGJCSemBYook z70Py38Yv3BcGcw/0vuifwOnIPsJWXMoPA5dhuNoRzxeHLmv3anwKNYN/73NHWJ3al3W VA9Q7bs3V81f7kEQFXz+VTcD/dhqjSCKP+iuFtYKCkNYcUtk+RSm2i7XCncVrXsR5oM1 gJz88Iw1YyIMZtg/5+RpIq9viIp3WX/OwCkiUYAnnub2L7m9BdsRRylHs7fKDqRKo0H6 SaLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=JNCO6xxGMkcdib2z4zEwPrhl1AuTZlBAkdZZQBMoJ70=; b=bjoLwavcNIzeht3SnUvS1cuoFLa6e6Q+VYuGVoRVZmB9fvdsFOxGjZjTeia+6ZZ62E If2e8+BFA7m09Ub5re1OWw6ubgk5Im+xNsnqOmh3WYBO8RpV+bUS1w7yzNI9fDNmhCwH W7uK8Mc3z7kqgO97yaMiWFWWJL4RofXBaU1vpd8W58nyDcRWATkzj2+uz1BazU2GBBI1 bdEd4IFyLrOBnt+8APk7vWkGr14x2s9lJBQ/lf3VnJjOK1FC99BgBmvpiFm1i+K1dU5O 7j6YhpTNZhhZs0sGuJpUP8IVPkX6nogF9v2CNqfurTcSIC+ygv9NPO0gbzUd2MguZKtz CEIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=42DS6C9Q; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t22-20020a056402525600b004314e4f40b3si15726779edd.604.2022.06.09.01.22.50; Thu, 09 Jun 2022 01:23:17 -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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=42DS6C9Q; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238710AbiFIHfU (ORCPT + 99 others); Thu, 9 Jun 2022 03:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236763AbiFIHfQ (ORCPT ); Thu, 9 Jun 2022 03:35:16 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81EEE1A05A for ; Thu, 9 Jun 2022 00:35:14 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id s135so5464183pgs.10 for ; Thu, 09 Jun 2022 00:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JNCO6xxGMkcdib2z4zEwPrhl1AuTZlBAkdZZQBMoJ70=; b=42DS6C9QAdOWkd4ugKBoSqNcOX/jjGsn2CabYnajx+nK8AZ7cpx+/kKTtME6+1yIFN xAQuAZGMH3I1GUe3o8OzqVULAiaC/KV1HqZeEZsnCZQ3ErOTpZqbWLU84JIPs754wLL0 0UVq5ie3X9KeaY9pw2XWHn1D/7bBKVMAULD3FUKyQCTCP48PuMW6a0fxwp/2j9lFboVG /hFXwM/+ztFxNoKlpxeBPO+vYUCmCG3pyZ2zmAKT5el+1WVzLdomTaBCXIMNyDgct+3L sjeYbvAWpIlpO88gfM9Hw6967VQ3/a5nkDQpaoHEpmSwqr4rfkLUcrYYPMTPr2fKkzUj kDew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JNCO6xxGMkcdib2z4zEwPrhl1AuTZlBAkdZZQBMoJ70=; b=K0gDkPWroGZahttBwrOACwaz2u9wqK6b5VF0UDupnjlTpOYkkP1aeo0fb1ecs7ZvxO 4yA+Up5ylE2Ia3d/ecuCgj/u0YF7XLefrB4wR4z7LzhizxvvdpBdX6MfezXRJFGaMVwn 6gvs39HHGdBV9TMJCKSkmvBUXTGWi+fyktUIwPc13V6+XLizaifm/WBJC4gvUJYYLkDN exNoZQUetZHwMY7VphEK4bJOc3/uPADAWhye3hfeq274/a2DxP/dP5z0rMTlnywaM33Y V2KfkolhdF+NBtRxbEIRU9etgAjfeNHUxiTN0uqXb9z/kl6N6sBv+AcuFJK+i5Y0usQa Ptgg== X-Gm-Message-State: AOAM530vkcQYQuCiewDFYuTVYDIqOazIY5JAmL8sHbl/nUsmpCnO6zhP n74xXnYWj4jIceKqaMnhxn5zdg== X-Received: by 2002:a05:6a00:21c8:b0:4fd:f89f:ec0e with SMTP id t8-20020a056a0021c800b004fdf89fec0emr38773986pfj.83.1654760114016; Thu, 09 Jun 2022 00:35:14 -0700 (PDT) Received: from C02CV1DAMD6P.bytedance.net ([139.177.225.224]) by smtp.gmail.com with ESMTPSA id g2-20020aa79f02000000b005185407eda5sm16484841pfr.44.2022.06.09.00.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 00:35:13 -0700 (PDT) From: Chengming Zhou To: tj@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH 1/2] blk-iocost: remove the second superfluous current_hweight Date: Thu, 9 Jun 2022 15:34:49 +0800 Message-Id: <20220609073450.98975-1-zhouchengming@bytedance.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 commit ac33e91e2dac ("blk-iocost: implement vtime loss compensation") add the second current_hweight() in the loop of active iocgs list to get old_hwi to calculate the vtime loss of the iocg. Since the hwi can't change and the first current_hweight already get hwa and hwi, so this second superfluous current_hweight() can be removed. There should be no functional changes. Signed-off-by: Chengming Zhou --- block/blk-iocost.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 33a11ba971ea..3cda08224d51 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2238,7 +2238,7 @@ static void ioc_timer_fn(struct timer_list *timer) /* calc usage and see whether some weights need to be moved around */ list_for_each_entry(iocg, &ioc->active_iocgs, active_list) { u64 vdone, vtime, usage_us; - u32 hw_active, hw_inuse; + u32 hwa, old_hwi; /* * Collect unused and wind vtime closer to vnow to prevent @@ -2246,7 +2246,7 @@ static void ioc_timer_fn(struct timer_list *timer) */ vdone = atomic64_read(&iocg->done_vtime); vtime = atomic64_read(&iocg->vtime); - current_hweight(iocg, &hw_active, &hw_inuse); + current_hweight(iocg, &hwa, &old_hwi); /* * Latency QoS detection doesn't account for IOs which are @@ -2271,15 +2271,15 @@ static void ioc_timer_fn(struct timer_list *timer) /* see whether there's surplus vtime */ WARN_ON_ONCE(!list_empty(&iocg->surplus_list)); - if (hw_inuse < hw_active || + if (old_hwi < hwa || (!waitqueue_active(&iocg->waitq) && time_before64(vtime, now.vnow - ioc->margins.low))) { - u32 hwa, old_hwi, hwm, new_hwi, usage; + u32 hwm, new_hwi, usage; u64 usage_dur; if (vdone != vtime) { u64 inflight_us = DIV64_U64_ROUND_UP( - cost_to_abs_cost(vtime - vdone, hw_inuse), + cost_to_abs_cost(vtime - vdone, old_hwi), ioc->vtime_base_rate); usage_us = max(usage_us, inflight_us); @@ -2300,7 +2300,6 @@ static void ioc_timer_fn(struct timer_list *timer) * Already donating or accumulated enough to start. * Determine the donation amount. */ - current_hweight(iocg, &hwa, &old_hwi); hwm = current_hweight_max(iocg); new_hwi = hweight_after_donation(iocg, old_hwi, hwm, usage, &now); -- 2.36.1