From patchwork Mon Oct 17 02:00:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008090 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 0A2BBC4332F for ; Mon, 17 Oct 2022 02:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbiJQCAS (ORCPT ); Sun, 16 Oct 2022 22:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbiJQCAS (ORCPT ); Sun, 16 Oct 2022 22:00:18 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4EA925283; Sun, 16 Oct 2022 19:00:16 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MrKqZ75l7zpVlL; Mon, 17 Oct 2022 09:56:58 +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:14 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 1/8] blk-iocost: Fix typo in comment Date: Mon, 17 Oct 2022 10:00:04 +0800 Message-ID: <20221017020011.25016-2-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 soley -> solely Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 495396425bad..be4bc38821e2 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -111,7 +111,7 @@ * busy signal. * * As devices can have deep queues and be unfair in how the queued commands - * are executed, soley depending on rq wait may not result in satisfactory + * are executed, solely depending on rq wait may not result in satisfactory * control quality. For a better control quality, completion latency QoS * parameters can be configured so that the device is considered saturated * if N'th percentile completion latency rises above the set point. From patchwork Mon Oct 17 02:00:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008091 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 86D91C43219 for ; Mon, 17 Oct 2022 02:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbiJQCAV (ORCPT ); Sun, 16 Oct 2022 22:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbiJQCAS (ORCPT ); Sun, 16 Oct 2022 22:00:18 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D874324F2D; Sun, 16 Oct 2022 19:00:17 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MrKny6ypvz1P7m7; Mon, 17 Oct 2022 09:55:34 +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:14 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 2/8] blk-iocost: Reset vtime_base_rate in ioc_refresh_params Date: Mon, 17 Oct 2022 10:00:05 +0800 Message-ID: <20221017020011.25016-3-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 Since commit ac33e91e2daca("blk-iocost: implement vtime loss compensation") split vtime_rate into vtime_rate and vtime_base_rate, we need reset both vtime_base_rate and vtime_rate when device parameters are refreshed. If vtime_base_rate is no reset here, vtime_rate will be overwritten with old vtime_base_rate soon in ioc_refresh_vrate. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-iocost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index be4bc38821e2..9214733bbc14 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -906,8 +906,10 @@ static bool ioc_refresh_params(struct ioc *ioc, bool force) if (idx == ioc->autop_idx && !force) return false; - if (idx != ioc->autop_idx) + if (idx != ioc->autop_idx) { atomic64_set(&ioc->vtime_rate, VTIME_PER_USEC); + ioc->vtime_base_rate = VTIME_PER_USEC; + } ioc->autop_idx = idx; ioc->autop_too_fast_at = 0; From patchwork Mon Oct 17 02:00:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008092 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 BD8F3C433FE for ; Mon, 17 Oct 2022 02:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbiJQCAU (ORCPT ); Sun, 16 Oct 2022 22:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbiJQCAT (ORCPT ); Sun, 16 Oct 2022 22:00:19 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4DB25C6B; Sun, 16 Oct 2022 19:00:18 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MrKrM38S7zJnTn; Mon, 17 Oct 2022 09:57:39 +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:15 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 3/8] blk-iocost: Trace vtime_base_rate instead of vtime_rate Date: Mon, 17 Oct 2022 10:00:06 +0800 Message-ID: <20221017020011.25016-4-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 Since commit ac33e91e2daca ("blk-iocost: implement vtime loss compensation") rename original vtime_base to vtime_base_rate and current vtime_base is original vtime_base with compensation. The current rate showed in tracepoint is mixed with vtime_base and vtime_base_rate: 1) In function ioc_adjust_base_vrate, the first trace_iocost_ioc_vrate_adj shows vtime_base, the second trace_iocost_ioc_vrate_adj shows vtime_base_rate. 2) In function iocg_activate shows vtime_base by calling TRACE_IOCG_PATH(iocg_activate... 3) In function ioc_check_iocgs shows vtime_base by calling TRACE_IOCG_PATH(iocg_idle... Trace vtime_base_rate instead of vtime_rate as: 1) Before commit ac33e91e2daca ("blk-iocost: implement vtime loss compensation"), the traced rate is without compensation, so still show rate without compensation. 2) The vtime_base_rate is more stable while vtime_rate heavily depends on excess budeget on current period which may change abruptly in next period. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-iocost.c | 2 +- include/trace/events/iocost.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 9214733bbc14..b0991b52e3dd 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -977,7 +977,7 @@ static void ioc_adjust_base_vrate(struct ioc *ioc, u32 rq_wait_pct, if (!ioc->busy_level || (ioc->busy_level < 0 && nr_lagging)) { if (ioc->busy_level != prev_busy_level || nr_lagging) - trace_iocost_ioc_vrate_adj(ioc, atomic64_read(&ioc->vtime_rate), + trace_iocost_ioc_vrate_adj(ioc, vrate, missed_ppm, rq_wait_pct, nr_lagging, nr_shortages); diff --git a/include/trace/events/iocost.h b/include/trace/events/iocost.h index 6d1626e7a4ce..af8bfed528fc 100644 --- a/include/trace/events/iocost.h +++ b/include/trace/events/iocost.h @@ -38,7 +38,7 @@ DECLARE_EVENT_CLASS(iocost_iocg_state, __assign_str(cgroup, path); __entry->now = now->now; __entry->vnow = now->vnow; - __entry->vrate = now->vrate; + __entry->vrate = iocg->ioc->vtime_base_rate; __entry->last_period = last_period; __entry->cur_period = cur_period; __entry->vtime = vtime; @@ -160,7 +160,7 @@ TRACE_EVENT(iocost_ioc_vrate_adj, TP_fast_assign( __assign_str(devname, ioc_name(ioc)); - __entry->old_vrate = atomic64_read(&ioc->vtime_rate); + __entry->old_vrate = ioc->vtime_base_rate; __entry->new_vrate = new_vrate; __entry->busy_level = ioc->busy_level; __entry->read_missed_ppm = missed_ppm[READ]; From patchwork Mon Oct 17 02:00:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008093 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 2A267C4321E for ; Mon, 17 Oct 2022 02:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230052AbiJQCAV (ORCPT ); Sun, 16 Oct 2022 22:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbiJQCAT (ORCPT ); Sun, 16 Oct 2022 22:00:19 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817FBDE2; Sun, 16 Oct 2022 19:00:18 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MrKrN0RsczJnTv; Mon, 17 Oct 2022 09:57:40 +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:16 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 4/8] blk-iocost: Remove vrate member in struct ioc_now Date: Mon, 17 Oct 2022 10:00:07 +0800 Message-ID: <20221017020011.25016-5-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 If we trace vtime_base_rate instead of vtime_rate, there is nowhere to access now->vrate except function ioc_now using now->vrate locally. Just clean it. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-iocost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index b0991b52e3dd..761295ed9c5a 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -556,7 +556,6 @@ struct ioc_now { u64 now_ns; u64 now; u64 vnow; - u64 vrate; }; struct iocg_wait { @@ -1020,10 +1019,11 @@ static void ioc_adjust_base_vrate(struct ioc *ioc, u32 rq_wait_pct, static void ioc_now(struct ioc *ioc, struct ioc_now *now) { unsigned seq; + u64 vrate; now->now_ns = ktime_get(); now->now = ktime_to_us(now->now_ns); - now->vrate = atomic64_read(&ioc->vtime_rate); + vrate = atomic64_read(&ioc->vtime_rate); /* * The current vtime is @@ -1036,7 +1036,7 @@ static void ioc_now(struct ioc *ioc, struct ioc_now *now) do { seq = read_seqcount_begin(&ioc->period_seqcount); now->vnow = ioc->period_at_vtime + - (now->now - ioc->period_at) * now->vrate; + (now->now - ioc->period_at) * vrate; } while (read_seqcount_retry(&ioc->period_seqcount, seq)); } From patchwork Mon Oct 17 02:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008094 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 1B75AC4332F for ; Mon, 17 Oct 2022 02:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbiJQCAW (ORCPT ); Sun, 16 Oct 2022 22:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbiJQCAU (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 238E326101; Sun, 16 Oct 2022 19:00:19 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MrKrN4WlhzJnTs; Mon, 17 Oct 2022 09:57:40 +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:16 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 5/8] blk-iocost: Correct comment in blk_iocost_init Date: Mon, 17 Oct 2022 10:00:08 +0800 Message-ID: <20221017020011.25016-6-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 There is no iocg_pd_init function. The pd_alloc_fn function pointer of iocost policy is set with ioc_pd_init. Just correct it. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 761295ed9c5a..96c1571a8a1d 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2880,7 +2880,7 @@ static int blk_iocost_init(struct gendisk *disk) spin_unlock_irq(&ioc->lock); /* - * rqos must be added before activation to allow iocg_pd_init() to + * rqos must be added before activation to allow ioc_pd_init() to * lookup the ioc from q. This means that the rqos methods may get * called before policy activation completion, can't assume that the * target bio has an iocg associated and need to test for NULL iocg. 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); /* From patchwork Mon Oct 17 02:00:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008096 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 C6783C433FE for ; Mon, 17 Oct 2022 02:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbiJQCAY (ORCPT ); Sun, 16 Oct 2022 22:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230080AbiJQCAV (ORCPT ); Sun, 16 Oct 2022 22:00:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BEF248E0; Sun, 16 Oct 2022 19:00:20 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MrKp14d6czmVCT; Mon, 17 Oct 2022 09:55:37 +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 7/8] blk-iocost: Remove redundant initialization of struct ioc_gq Date: Mon, 17 Oct 2022 10:00:10 +0800 Message-ID: <20221017020011.25016-8-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 Some member of struct ioc_gq will not be accessed before it's first activation and will be initialized again in it's first activation after ioc_pd_init. To be more specific: 1)Member iocg->vtime and iocg->done_vtime will set to target in activation which only expects vtime is equal to done_vtime in first activation. 2)Member iocg->active_period will be set with ioc->cur_period again in first activation. Remove the redundant initialization to improve ioc_pd_init a littile bit. The parameter now of weight_updated will not be used if iocg is not active, so pass NULL to weight_update here is safe and we can remove call to ioc_now. Signed-off-by: Kemeng Shi --- block/blk-iocost.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index fa90f471dfdc..4815e676733d 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2946,16 +2946,10 @@ static void ioc_pd_init(struct blkg_policy_data *pd) struct ioc_gq *iocg = pd_to_iocg(pd); struct blkcg_gq *blkg = pd_to_blkg(&iocg->pd); struct ioc *ioc = q_to_ioc(blkg->q); - struct ioc_now now; struct blkcg_gq *tblkg; unsigned long flags; - ioc_now(ioc, &now); - iocg->ioc = ioc; - atomic64_set(&iocg->vtime, now.vnow); - atomic64_set(&iocg->done_vtime, now.vnow); - atomic64_set(&iocg->active_period, atomic64_read(&ioc->cur_period)); INIT_LIST_HEAD(&iocg->active_list); INIT_LIST_HEAD(&iocg->walk_list); INIT_LIST_HEAD(&iocg->surplus_list); @@ -2974,7 +2968,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd) } spin_lock_irqsave(&ioc->lock, flags); - weight_updated(iocg, &now); + weight_updated(iocg, NULL); spin_unlock_irqrestore(&ioc->lock, flags); } From patchwork Mon Oct 17 02:00:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13008097 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 E525CC4332F for ; Mon, 17 Oct 2022 02:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbiJQCAZ (ORCPT ); Sun, 16 Oct 2022 22:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbiJQCAV (ORCPT ); Sun, 16 Oct 2022 22:00:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1817F26101; Sun, 16 Oct 2022 19:00:21 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MrKqg1lPtzpW9D; Mon, 17 Oct 2022 09:57:03 +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:18 +0800 From: Kemeng Shi To: , , , CC: Subject: [PATCH 8/8] blk-iocost: Get ioc_now inside weight_updated Date: Mon, 17 Oct 2022 10:00:11 +0800 Message-ID: <20221017020011.25016-9-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 ioc_now parameter of weight_updated is only needed if we need call propagate_weights. Move ioc_now inside weight_updated to remove unnecessary get of ioc_now from outside of weight_updated. Signed-off-by: Kemeng Shi --- block/blk-iocost.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 4815e676733d..e2aaf133deb8 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -1220,18 +1220,21 @@ static u32 current_hweight_max(struct ioc_gq *iocg) return max_t(u32, hwm, 1); } -static void weight_updated(struct ioc_gq *iocg, struct ioc_now *now) +static void weight_updated(struct ioc_gq *iocg) { struct ioc *ioc = iocg->ioc; struct blkcg_gq *blkg = iocg_to_blkg(iocg); struct ioc_cgrp *iocc = blkcg_to_iocc(blkg->blkcg); + struct ioc_now now; u32 weight; lockdep_assert_held(&ioc->lock); weight = iocg->cfg_weight ?: iocc->dfl_weight; - if (weight != iocg->weight && iocg->active) - propagate_weights(iocg, weight, iocg->inuse, true, now); + if (weight != iocg->weight && iocg->active) { + ioc_now(iocg->ioc, &now); + propagate_weights(iocg, weight, iocg->inuse, true, &now); + } iocg->weight = weight; } @@ -2968,7 +2971,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd) } spin_lock_irqsave(&ioc->lock, flags); - weight_updated(iocg, NULL); + weight_updated(iocg); spin_unlock_irqrestore(&ioc->lock, flags); } @@ -3053,7 +3056,6 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf, struct blkcg *blkcg = css_to_blkcg(of_css(of)); struct ioc_cgrp *iocc = blkcg_to_iocc(blkcg); struct blkg_conf_ctx ctx; - struct ioc_now now; struct ioc_gq *iocg; u32 v; int ret; @@ -3074,8 +3076,7 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf, if (iocg) { spin_lock(&iocg->ioc->lock); - ioc_now(iocg->ioc, &now); - weight_updated(iocg, &now); + weight_updated(iocg); spin_unlock(&iocg->ioc->lock); } } @@ -3101,8 +3102,7 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf, spin_lock(&iocg->ioc->lock); iocg->cfg_weight = v * WEIGHT_ONE; - ioc_now(iocg->ioc, &now); - weight_updated(iocg, &now); + weight_updated(iocg); spin_unlock(&iocg->ioc->lock); blkg_conf_finish(&ctx);