Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1315264iob; Fri, 29 Apr 2022 02:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQtkrb2IVMfuNZsa0C5ZEoFHj4vhRx+RNWQRWq5uxmBgG18qdL4Q/q1dSHwHPR9egef4C4 X-Received: by 2002:a05:6512:33c2:b0:472:33dd:9f46 with SMTP id d2-20020a05651233c200b0047233dd9f46mr6883090lfg.98.1651225249583; Fri, 29 Apr 2022 02:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651225249; cv=none; d=google.com; s=arc-20160816; b=qAt85hVKjOtF3BepZJtV34dfq+TY9662ukJv94NPv9gapA4I1c51oUGctuEeN16twf n2NcfTc4ehtsC1A8xqrjk57eVjXOP0hIRLDzh+RaDEv07MT4gXY+aILLD1HQ0bCob44A Gkm9MuPw4CUmPh8ESHva41MjTBm5t9PgF42rMDQSHjAAh8u4cQTTlKYmDdGjncNJnPGf 5XgIsAW5bsaAA/BhPVBsNKfFXsIqG56qg3PZg+SB+jS0R1JvQluZEU8SKSkBqJ3zUkm1 6P8PyA4oazj5xOiYt2xtPOm4qhvbYZ2aOz3WaOrfBKLqHeGy+OYglUuh2FRXtUqPn/AE UCZQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JFN5LKYL9shlXilFjFn1PHKuKVDbnHT5Y9F5+PXrMqI=; b=Jtw6ETAI7P6/r5cep2WC74jOk7Aju3M2fc5Q7p/YPjpXfgaO16d3JTcGHCwYsD+sX9 X7dyr9XwIghusQ/H2nGV88tIgtd4ykXM7zDeJAwShUZeE7qH/j11iKX3J6bqd8NiFvKO Nw93lnGgtjRONMpTWju0QwKXEGn9ytmCtc5fXLEu3X+YMZx9hwlMcbiSDMDK939DWflP yAMwNGzs75syOzFcMQnfsIMnw5J+6r9dT58iWef6cFazjhxzOi143EZ/lDJKzJmL1D5x /BeDihuKOZNeu0ue/kEMzeYQpReu30NkFZS7XoszK+k8m7fDqMo9W6u99Fou7Lg4y9WF nYtw== 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 b22-20020a0565120b9600b0046bb7f63c90si7832015lfv.157.2022.04.29.02.40.20; Fri, 29 Apr 2022 02:40:49 -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 S1345757AbiD1L5s (ORCPT + 99 others); Thu, 28 Apr 2022 07:57:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345734AbiD1L5n (ORCPT ); Thu, 28 Apr 2022 07:57:43 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD5AD84ED4; Thu, 28 Apr 2022 04:54:28 -0700 (PDT) Received: from kwepemi500022.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KpvCy60pzzhYqf; Thu, 28 Apr 2022 19:54:06 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500022.china.huawei.com (7.221.188.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 19:54:26 +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; Thu, 28 Apr 2022 19:54:25 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v5 1/3] block, bfq: record how many queues are busy in bfq_group Date: Thu, 28 Apr 2022 20:08:35 +0800 Message-ID: <20220428120837.3737765-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220428120837.3737765-1-yukuai3@huawei.com> References: <20220428120837.3737765-1-yukuai3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600009.china.huawei.com (7.193.23.164) 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 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 | 20 ++++++++++++++++++++ 3 files changed, 23 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..d9ff33e0be38 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -218,6 +218,16 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) return false; } +static void bfq_inc_busy_queues(struct bfq_queue *bfqq) +{ + bfqq_group(bfqq)->busy_queues++; +} + +static void bfq_dec_busy_queues(struct bfq_queue *bfqq) +{ + bfqq_group(bfqq)->busy_queues--; +} + #else /* CONFIG_BFQ_GROUP_IOSCHED */ static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) @@ -230,6 +240,14 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) return true; } +static void bfq_inc_busy_queues(struct bfq_queue *bfqq) +{ +} + +static void bfq_dec_busy_queues(struct bfq_queue *bfqq) +{ +} + #endif /* CONFIG_BFQ_GROUP_IOSCHED */ /* @@ -1660,6 +1678,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_inc_busy_queues(bfqq); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues--; @@ -1683,6 +1702,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_dec_busy_queues(bfqq); if (!bfqq->dispatched) if (bfqq->wr_coeff == 1) -- 2.31.1