From patchwork Wed Apr 27 12:47:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 12828771 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 51EA7C433F5 for ; Wed, 27 Apr 2022 12:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234169AbiD0MgY (ORCPT ); Wed, 27 Apr 2022 08:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234069AbiD0MgX (ORCPT ); Wed, 27 Apr 2022 08:36:23 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73371FD31; Wed, 27 Apr 2022 05:33:12 -0700 (PDT) Received: from kwepemi100003.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KpJ6S1Wf3zfZrg; Wed, 27 Apr 2022 20:32:16 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi100003.china.huawei.com (7.221.188.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:33:10 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:33:09 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v3 1/3] block, bfq: record how many queues are busy in bfq_group Date: Wed, 27 Apr 2022 20:47:20 +0800 Message-ID: <20220427124722.48465-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220427124722.48465-1-yukuai3@huawei.com> References: <20220427124722.48465-1-yukuai3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Prepare to refactor the counting of 'num_groups_with_pending_reqs'. Add a counter 'busy_queues' in bfq_group, and update it in bfq_add/del_bfqq_busy(). Signed-off-by: Yu Kuai --- block/bfq-cgroup.c | 1 + block/bfq-iosched.h | 2 ++ block/bfq-wf2q.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 09574af83566..4d516879d9fa 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -557,6 +557,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd) */ bfqg->bfqd = bfqd; bfqg->active_entities = 0; + bfqg->busy_queues = 0; bfqg->online = true; bfqg->rq_pos_tree = RB_ROOT; } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 978ef5d6fe6a..3847f4ab77ac 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -906,6 +906,7 @@ struct bfq_group_data { * are groups with more than one active @bfq_entity * (see the comments to the function * bfq_bfqq_may_idle()). + * @busy_queues: number of busy bfqqs. * @rq_pos_tree: rbtree sorted by next_request position, used when * determining if two or more queues have interleaving * requests (see bfq_find_close_cooperator()). @@ -942,6 +943,7 @@ struct bfq_group { struct bfq_entity *my_entity; int active_entities; + int busy_queues; struct rb_root rq_pos_tree; diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index f8eb340381cf..53826797430f 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -218,6 +218,14 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) return false; } +static void bfq_update_busy_queues(struct bfq_queue *bfqq, bool is_add) +{ + if (is_add) + bfqq_group(bfqq)->busy_queues++; + else + bfqq_group(bfqq)->busy_queues--; +} + #else /* CONFIG_BFQ_GROUP_IOSCHED */ static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) @@ -230,6 +238,10 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) return true; } +static void bfq_update_busy_queues(struct bfq_queue *bfqq, bool is_add) +{ +} + #endif /* CONFIG_BFQ_GROUP_IOSCHED */ /* @@ -1660,6 +1672,7 @@ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, bfq_clear_bfqq_busy(bfqq); bfqd->busy_queues[bfqq->ioprio_class - 1]--; + bfq_update_busy_queues(bfqq, false); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues--; @@ -1683,6 +1696,7 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) bfq_mark_bfqq_busy(bfqq); bfqd->busy_queues[bfqq->ioprio_class - 1]++; + bfq_update_busy_queues(bfqq, true); if (!bfqq->dispatched) if (bfqq->wr_coeff == 1)