Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1274263pxb; Sat, 16 Apr 2022 03:57:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxJqwlA8pCxtnT/kKZ8aaAvng+53RDHWo8Mv/sOrQ0zoc/wNp12bztbhAH6soD6VaNtv8v X-Received: by 2002:a17:90b:4a83:b0:1c6:f037:bc73 with SMTP id lp3-20020a17090b4a8300b001c6f037bc73mr8649289pjb.44.1650106674187; Sat, 16 Apr 2022 03:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650106674; cv=none; d=google.com; s=arc-20160816; b=VjdpaZAjJtJHy5CRedAPbBDxtPUSdDQ/xE8ZVQVM6/uDAz6w3sMXQt7W1s8fxE68Xn y9FGiMxsDj1/8iZ+hB0PqLhi3UjtpnFVvCR/K8lRv6xeEsuN9Hl0i9xdpUJUwLVdjUuM BSc7YoReR2w0fv8TUCTBIYBp9w8/3zLTJEMVbeUvB1vjKi56t3cIkaJr5MmIQmcVkjLz 01o4xxB00YBQeRN0EUTw9L4oWp51JD81hAYo2nXRI7XY+1rP8UT9b/xWCrCfv71DpgZ4 gQPOAg9eFzpVxj/Ob5uGa8Vyr5yzEuo8PQb+ezC7d6b1fz9Gp3R2OpBxWFqDN1yazqhB jJ2w== 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=RSn2+NDKV38e0L1XZSbYtNKpBfu3AJe0che9SbFue8I=; b=RJVOoG8swKz1/cditEtOQBkYFmI2woWzLGyWgiZCZ1ozz+rqujfchglnq/QFHCBRMf 3It0zhb8t0YKXX5b/OEDeS3cz0Hjek115JyEGb+eOoSlPk4AN5ahRN8wXISkPCMbY0/Q FdcjcRE+LW8nP7Q/3ZZ33fDZ061ijazmPf7FOcTggUVHQBPTL6WjnMv64Et0bJHFZbVt Ti4DRl+apxVQjmSwv9z/A+SzTkb7JM+NmCJOAb79uwMpzxDZKY7QnAJ9CS3hdYgfzJwN c2nqN3j5Mrp+eJ0VcS9DvtV2OPENhBV1kPA6yX0rRYFOoKqDdRQWDHbPLRFfFHM/b8nN FKPA== 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 s200-20020a632cd1000000b0039f0abb5197si3652299pgs.29.2022.04.16.03.57.40; Sat, 16 Apr 2022 03:57:54 -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 S231245AbiDPJ0C (ORCPT + 99 others); Sat, 16 Apr 2022 05:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbiDPJZ7 (ORCPT ); Sat, 16 Apr 2022 05:25:59 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 614B110F4; Sat, 16 Apr 2022 02:23:28 -0700 (PDT) Received: from kwepemi100021.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KgSRc3wLKzQjCx; Sat, 16 Apr 2022 17:23:24 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi100021.china.huawei.com (7.221.188.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 16 Apr 2022 17:23: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; Sat, 16 Apr 2022 17:23:25 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v2 1/5] block, bfq: cleanup bfq_weights_tree add/remove apis Date: Sat, 16 Apr 2022 17:37:49 +0800 Message-ID: <20220416093753.3054696-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220416093753.3054696-1-yukuai3@huawei.com> References: <20220416093753.3054696-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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 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 --- block/bfq-iosched.c | 14 +++++++------- block/bfq-iosched.h | 7 ++----- block/bfq-wf2q.c | 16 +++++----------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2e0dd68a3cbe..2deea2d07a1f 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -862,9 +862,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; @@ -936,13 +936,14 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq, * See the comments to the function bfq_weights_tree_add() for considerations * about overhead. */ -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) { + 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; @@ -1004,8 +1005,7 @@ void bfq_weights_tree_remove(struct bfq_data *bfqd, * has no dispatched request. DO NOT use bfqq after the next * function invocation. */ - __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 3b83e3d1c2e5..072099b0c11a 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -969,11 +969,8 @@ 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_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, diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index f8eb340381cf..a1296058c1ec 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -707,7 +707,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; @@ -770,19 +769,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; @@ -1686,8 +1681,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