Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp1999975lfo; Sat, 28 May 2022 13:18:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYP8FIn2aiBJmvWoFHGeudUAjLzfiVJaKnoUb6KxS7O5KfOFtkQZ2n4XpRF6n3oM6+Josw X-Received: by 2002:aa7:8dd8:0:b0:518:11:18db with SMTP id j24-20020aa78dd8000000b00518001118dbmr50042520pfr.29.1653769136752; Sat, 28 May 2022 13:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769136; cv=none; d=google.com; s=arc-20160816; b=GzxKcwrp9Geue2eOUXe4e5b/YktLLkdJejC+Aw/ZAN+dLu076ldqL5phuFit2Vm/uI kQ/5WciV3DLYhBso/M+L9+nfl/NGT+NbKdGoHtlCNSFagqao65fWgYJeGg6j4m8w6CPg cw6Gjkj3Rtp60U82mevimSiexwJEIfa5afd/qqDGFWb/trp3I5klmeCAsd48JNKxOWdu KdSsvoLSk7qkP+XIUAm9IKffP1nCXq4R9WoUBUAN31JVwTRwfqtTjsv7kwoT4cwkuKLW uAWHdJn7V6aQoWoL61ZemKyWJQdFeIufNycvTEjC0PE8IRWxnEHgnVuUXFPd3Q60ylVb l1wg== 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=/AAKPGI/Jc/kYr6AQnWG9hb36p3IIpO29I0Jf65QVIo=; b=HBGweiCLByf859Z1skNRsFRnoy9pXZMFmXS0on/iEp8GX2l2ca2vnib8cQVsLfqi06 7VQkT8iVJhurH6etImN5wdUd7VWpSZyQuJHRf/w9LxaIrsojJK8OqsacU3KkRPJdnwj0 V10iE/NDzk36J+xn1+4Qst74EKcf+aM62RkSTwJgGAvz3zEK2uGF9GhnWHZLb2AnYtH8 qAtw++BudJlKXqc4n0VmwK0wxQSZfMAj8mNYtjVg3yFcfCKQWiR8FbyHEpFGpYl3SlyD srDnh1cO014Fi/pQV7ZumgL2xwRLAcg01+l1L4KUWrorTtaV+GD7Rtcztwv1LwqMdTdu OWig== 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 q20-20020a170902b11400b001634bdcdc5dsi9363107plr.342.2022.05.28.13.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:18:56 -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 6FDD454F98; Sat, 28 May 2022 12:29:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351254AbiE1Jqm (ORCPT + 99 others); Sat, 28 May 2022 05:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233365AbiE1Jqc (ORCPT ); Sat, 28 May 2022 05:46:32 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC1A165AD; Sat, 28 May 2022 02:46:30 -0700 (PDT) Received: from kwepemi500019.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L9Gx23ckbzgYNt; Sat, 28 May 2022 17:44:54 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500019.china.huawei.com (7.221.188.117) 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:46:29 +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:46:28 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v3 1/6] block, bfq: cleanup bfq_weights_tree add/remove apis Date: Sat, 28 May 2022 17:59:53 +0800 Message-ID: <20220528095958.270455-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220528095958.270455-1-yukuai3@huawei.com> References: <20220528095958.270455-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: dggems705-chm.china.huawei.com (10.3.19.182) 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 They already pass 'bfqd' as the first parameter, there is no need to pass 'bfqd->queue_weights_tree' as another parameter. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara --- block/bfq-iosched.c | 13 +++++++------ block/bfq-iosched.h | 10 +++------- block/bfq-wf2q.c | 16 +++++----------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index ffbc2d1593af..2315cfbe46e7 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -870,9 +870,9 @@ static bool bfq_asymmetric_scenario(struct bfq_data *bfqd, * In most scenarios, the rate at which nodes are created/destroyed * should be low too. */ -void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq, - struct rb_root_cached *root) +void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq) { + struct rb_root_cached *root = &bfqd->queue_weights_tree; struct bfq_entity *entity = &bfqq->entity; struct rb_node **new = &(root->rb_root.rb_node), *parent = NULL; bool leftmost = true; @@ -945,12 +945,14 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq, * about overhead. */ void __bfq_weights_tree_remove(struct bfq_data *bfqd, - struct bfq_queue *bfqq, - struct rb_root_cached *root) + struct bfq_queue *bfqq) { + struct rb_root_cached *root; + if (!bfqq->weight_counter) return; + root = &bfqd->queue_weights_tree; bfqq->weight_counter->num_active--; if (bfqq->weight_counter->num_active > 0) goto reset_entity_pointer; @@ -970,8 +972,7 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd, void bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bfqq) { - __bfq_weights_tree_remove(bfqd, bfqq, - &bfqd->queue_weights_tree); + __bfq_weights_tree_remove(bfqd, bfqq); } /* diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 6c6cd984d769..50c554134196 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -933,13 +933,9 @@ struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync); void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, bool is_sync); struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic); void bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq); -void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq, - struct rb_root_cached *root); -void __bfq_weights_tree_remove(struct bfq_data *bfqd, - struct bfq_queue *bfqq, - struct rb_root_cached *root); -void bfq_weights_tree_remove(struct bfq_data *bfqd, - struct bfq_queue *bfqq); +void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq); +void __bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bfqq); +void bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bfqq); void bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq, bool compensate, enum bfqq_expiration reason); void bfq_put_queue(struct bfq_queue *bfqq); diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 48ca7922035c..03949c20494d 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -731,7 +731,6 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); unsigned int prev_weight, new_weight; struct bfq_data *bfqd = NULL; - struct rb_root_cached *root; #ifdef CONFIG_BFQ_GROUP_IOSCHED struct bfq_sched_data *sd; struct bfq_group *bfqg; @@ -794,19 +793,15 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, * queue, remove the entity from its old weight counter (if * there is a counter associated with the entity). */ - if (prev_weight != new_weight && bfqq) { - root = &bfqd->queue_weights_tree; - __bfq_weights_tree_remove(bfqd, bfqq, root); - } + if (prev_weight != new_weight && bfqq) + __bfq_weights_tree_remove(bfqd, bfqq); entity->weight = new_weight; /* * Add the entity, if it is not a weight-raised queue, * to the counter associated with its new weight. */ - if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) { - /* If we get here, root has been initialized. */ - bfq_weights_tree_add(bfqd, bfqq, root); - } + if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) + bfq_weights_tree_add(bfqd, bfqq); new_st->wsum += entity->weight; @@ -1697,8 +1692,7 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) if (!bfqq->dispatched) if (bfqq->wr_coeff == 1) - bfq_weights_tree_add(bfqd, bfqq, - &bfqd->queue_weights_tree); + bfq_weights_tree_add(bfqd, bfqq); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues++; -- 2.31.1