Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2432963ioo; Sat, 28 May 2022 13:30:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxStrM+jDrH7ifaqY2Oxc++MSBWgfx4f8vmG8/Kc0cTzU419LvZOkZsrX7itDkN2ulQEeDb X-Received: by 2002:a17:902:7c0a:b0:15e:f63b:9a14 with SMTP id x10-20020a1709027c0a00b0015ef63b9a14mr49507112pll.35.1653769841641; Sat, 28 May 2022 13:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769841; cv=none; d=google.com; s=arc-20160816; b=ncQf6Hi5AeqhtGYWMcjXPeNt3tBxGZIIS0HoFb8TVEJKsSpPuN7qQsNvipq4Wtffwg 4eMGLXo/0OQKggWgb/dDK5to94DpssHnMROlAw/9zmWTAUK70ytD5F/R60yty32Oy3SD sWxhEAJ+AdCyz86s9n3rkdeuB5FKSpzGSpvTG5NbbJ4mltif7i3/t1tbBZAE5NoXV9YI aCvMMmeKroBFrLCcp09LWuw28nrIHznXnD+wZxjbssmJyMhpzpHpRwG85q9/2osqMir/ BPrbuz7J/YRfHdM+QTG8tKP3wIkyGQue1jT0At6Ie4qehDyoM+MgXCHm7gG8+L9wtyDN XAig== 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=0PLJ0jTeFOR7+Rf+NZmX9iM1OSAXB60OuvMoqOisQGQ=; b=qVCn8YUf5TC2uGloj9jSwNQOGHKZ9h1C1VCeD/KKS5qBvfuZkSTLJHQa/HqMAfU0dI ji6TSSh5wY0zOtnrid+WjKHKHIFMv09XM1cRJhfufXDhDSDmz5ge1wAzZDPTW58MKhx4 RqCENs55NBSZxq42mAOAFaBOwZKU/4AkDdIwFCaJ9SZ+PkDr0h5iSaxGOVy7s71DD3OG rzP5qF0ZbU8X6m8QZ5sUZY7X6GttVYik0LGimSwvecRLkt+j+yjkkl9NzsVHd8ZAO+uM g+n/0r5dFiRmnfQdLCveMsa9rRt/hHEcLZ0AyaBitvkrLlHol5oxUkKRrgC/XqytAUBQ aKwg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v135-20020a63618d000000b003fbac5bc943si6126689pgb.477.2022.05.28.13.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:30:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7409113641E; Sat, 28 May 2022 12:40:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232995AbiE1JhC (ORCPT + 99 others); Sat, 28 May 2022 05:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiE1Jg4 (ORCPT ); Sat, 28 May 2022 05:36:56 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FA34167C9; Sat, 28 May 2022 02:36:53 -0700 (PDT) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L9Gks1XttzjX6L; Sat, 28 May 2022 17:36:05 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 28 May 2022 17:36:51 +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; Sat, 28 May 2022 17:36:50 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v7 1/3] block, bfq: record how many queues are busy in bfq_group Date: Sat, 28 May 2022 17:50:18 +0800 Message-ID: <20220528095020.186970-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220528095020.186970-1-yukuai3@huawei.com> References: <20220528095020.186970-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: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Reviewed-by: Jan Kara --- block/bfq-cgroup.c | 1 + block/bfq-iosched.h | 2 ++ block/bfq-wf2q.c | 26 ++++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) 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 ca8177d7bf7c..d92adbdd70ee 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -907,6 +907,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()). @@ -943,6 +944,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..b97e33688335 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -218,6 +218,18 @@ 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->bfqd->busy_queues[bfqq->ioprio_class - 1]++; + bfqq_group(bfqq)->busy_queues++; +} + +static void bfq_dec_busy_queues(struct bfq_queue *bfqq) +{ + bfqq->bfqd->busy_queues[bfqq->ioprio_class - 1]--; + bfqq_group(bfqq)->busy_queues--; +} + #else /* CONFIG_BFQ_GROUP_IOSCHED */ static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) @@ -230,6 +242,16 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) return true; } +static void bfq_inc_busy_queues(struct bfq_queue *bfqq) +{ + bfqq->bfqd->busy_queues[bfqq->ioprio_class - 1]++; +} + +static void bfq_dec_busy_queues(struct bfq_queue *bfqq) +{ + bfqq->bfqd->busy_queues[bfqq->ioprio_class - 1]--; +} + #endif /* CONFIG_BFQ_GROUP_IOSCHED */ /* @@ -1659,7 +1681,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_dec_busy_queues(bfqq); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues--; @@ -1682,7 +1704,7 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) bfq_activate_bfqq(bfqd, bfqq); bfq_mark_bfqq_busy(bfqq); - bfqd->busy_queues[bfqq->ioprio_class - 1]++; + bfq_inc_busy_queues(bfqq); if (!bfqq->dispatched) if (bfqq->wr_coeff == 1) -- 2.31.1