From nobody Tue May 21 04:49:05 2024 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 4A056C433F5 for ; Sat, 28 May 2022 09:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349308AbiE1Jqn (ORCPT ); Sat, 28 May 2022 05:46:43 -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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Paolo Valente --- 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 *bf= qd, * 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 =3D &bfqd->queue_weights_tree; struct bfq_entity *entity =3D &bfqq->entity; struct rb_node **new =3D &(root->rb_root.rb_node), *parent =3D NULL; bool leftmost =3D true; @@ -945,12 +945,14 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, stru= ct 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; =20 + root =3D &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); } =20 /* 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, b= ool is_sync); void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, bool is_s= ync); 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 *bf= qq); +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 =3D bfq_entity_to_bfqq(entity); unsigned int prev_weight, new_weight; struct bfq_data *bfqd =3D 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_tr= ee *old_st, * queue, remove the entity from its old weight counter (if * there is a counter associated with the entity). */ - if (prev_weight !=3D new_weight && bfqq) { - root =3D &bfqd->queue_weights_tree; - __bfq_weights_tree_remove(bfqd, bfqq, root); - } + if (prev_weight !=3D new_weight && bfqq) + __bfq_weights_tree_remove(bfqd, bfqq); entity->weight =3D new_weight; /* * Add the entity, if it is not a weight-raised queue, * to the counter associated with its new weight. */ - if (prev_weight !=3D new_weight && bfqq && bfqq->wr_coeff =3D=3D 1) { - /* If we get here, root has been initialized. */ - bfq_weights_tree_add(bfqd, bfqq, root); - } + if (prev_weight !=3D new_weight && bfqq && bfqq->wr_coeff =3D=3D 1) + bfq_weights_tree_add(bfqd, bfqq); =20 new_st->wsum +=3D entity->weight; =20 @@ -1697,8 +1692,7 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct = bfq_queue *bfqq) =20 if (!bfqq->dispatched) if (bfqq->wr_coeff =3D=3D 1) - bfq_weights_tree_add(bfqd, bfqq, - &bfqd->queue_weights_tree); + bfq_weights_tree_add(bfqd, bfqq); =20 if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues++; --=20 2.31.1 From nobody Tue May 21 04:49:05 2024 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 2353BC433F5 for ; Sat, 28 May 2022 09:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350157AbiE1Jqr (ORCPT ); Sat, 28 May 2022 05:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233336AbiE1Jqc (ORCPT ); Sat, 28 May 2022 05:46:32 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8126065D3; Sat, 28 May 2022 02:46:31 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4L9Gx33w2cz1JCBM; Sat, 28 May 2022 17:44:55 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500012.china.huawei.com (7.221.188.12) 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:29 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v3 2/6] block, bfq: cleanup __bfq_weights_tree_remove() Date: Sat, 28 May 2022 17:59:54 +0800 Message-ID: <20220528095958.270455-3-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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's the same with bfq_weights_tree_remove() now. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara Acked-by: Paolo Valente --- block/bfq-iosched.c | 13 +------------ block/bfq-iosched.h | 1 - block/bfq-wf2q.c | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2315cfbe46e7..8c7020f8cdf2 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -944,8 +944,7 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct= bfq_queue *bfqq) * See the comments to the function bfq_weights_tree_add() for considerati= ons * about overhead. */ -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) { struct rb_root_cached *root; =20 @@ -965,16 +964,6 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd, bfq_put_queue(bfqq); } =20 -/* - * Invoke __bfq_weights_tree_remove on bfqq and decrement the number - * of active groups for each queue's inactive parent entity. - */ -void bfq_weights_tree_remove(struct bfq_data *bfqd, - struct bfq_queue *bfqq) -{ - __bfq_weights_tree_remove(bfqd, bfqq); -} - /* * Return expired entry, or NULL to just start from scratch in rbtree. */ diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 50c554134196..ecca2c0570ea 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -934,7 +934,6 @@ void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_que= ue *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); -void __bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bf= qq); 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); diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 03949c20494d..44905ed5175d 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -794,7 +794,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree= *old_st, * there is a counter associated with the entity). */ if (prev_weight !=3D new_weight && bfqq) - __bfq_weights_tree_remove(bfqd, bfqq); + bfq_weights_tree_remove(bfqd, bfqq); entity->weight =3D new_weight; /* * Add the entity, if it is not a weight-raised queue, --=20 2.31.1 From nobody Tue May 21 04:49:05 2024 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 D4DABC433F5 for ; Sat, 28 May 2022 09:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354616AbiE1Jqw (ORCPT ); Sat, 28 May 2022 05:46:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233395AbiE1Jqd (ORCPT ); Sat, 28 May 2022 05:46:33 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D035764F; Sat, 28 May 2022 02:46:32 -0700 (PDT) Received: from kwepemi500014.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L9Gy02d6LzjX5R; Sat, 28 May 2022 17:45:44 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500014.china.huawei.com (7.221.188.232) 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:30 +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:29 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v3 3/6] block, bfq: factor out code to update 'active_entities' Date: Sat, 28 May 2022 17:59:55 +0800 Message-ID: <20220528095958.270455-4-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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Current code is a bit ugly and hard to read. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara Acked-by: Paolo Valente --- block/bfq-wf2q.c | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 44905ed5175d..643e57ee3e64 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -232,6 +232,26 @@ static void bfq_dec_busy_queues(struct bfq_queue *bfqq) bfqq->bfqd->num_groups_with_busy_queues--; } =20 +static void bfq_inc_active_entities(struct bfq_entity *entity) +{ + struct bfq_sched_data *sd =3D entity->sched_data; + struct bfq_group *bfqg =3D container_of(sd, struct bfq_group, sched_data); + struct bfq_data *bfqd =3D (struct bfq_data *)bfqg->bfqd; + + if (bfqg !=3D bfqd->root_group) + bfqg->active_entities++; +} + +static void bfq_dec_active_entities(struct bfq_entity *entity) +{ + struct bfq_sched_data *sd =3D entity->sched_data; + struct bfq_group *bfqg =3D container_of(sd, struct bfq_group, sched_data); + struct bfq_data *bfqd =3D (struct bfq_data *)bfqg->bfqd; + + if (bfqg !=3D bfqd->root_group) + bfqg->active_entities--; +} + #else /* CONFIG_BFQ_GROUP_IOSCHED */ =20 static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) @@ -254,6 +274,14 @@ static void bfq_dec_busy_queues(struct bfq_queue *bfqq) bfqq->bfqd->busy_queues[bfqq->ioprio_class - 1]--; } =20 +static void bfq_inc_active_entities(struct bfq_entity *entity) +{ +} + +static void bfq_dec_active_entities(struct bfq_entity *entity) +{ +} + #endif /* CONFIG_BFQ_GROUP_IOSCHED */ =20 /* @@ -480,11 +508,6 @@ static void bfq_active_insert(struct bfq_service_tree = *st, { struct bfq_queue *bfqq =3D bfq_entity_to_bfqq(entity); struct rb_node *node =3D &entity->rb_node; -#ifdef CONFIG_BFQ_GROUP_IOSCHED - struct bfq_sched_data *sd =3D NULL; - struct bfq_group *bfqg =3D NULL; - struct bfq_data *bfqd =3D NULL; -#endif =20 bfq_insert(&st->active, entity); =20 @@ -495,17 +518,10 @@ static void bfq_active_insert(struct bfq_service_tree= *st, =20 bfq_update_active_tree(node); =20 -#ifdef CONFIG_BFQ_GROUP_IOSCHED - sd =3D entity->sched_data; - bfqg =3D container_of(sd, struct bfq_group, sched_data); - bfqd =3D (struct bfq_data *)bfqg->bfqd; -#endif if (bfqq) list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list); -#ifdef CONFIG_BFQ_GROUP_IOSCHED - if (bfqg !=3D bfqd->root_group) - bfqg->active_entities++; -#endif + + bfq_inc_active_entities(entity); } =20 /** @@ -582,29 +598,16 @@ static void bfq_active_extract(struct bfq_service_tre= e *st, { struct bfq_queue *bfqq =3D bfq_entity_to_bfqq(entity); struct rb_node *node; -#ifdef CONFIG_BFQ_GROUP_IOSCHED - struct bfq_sched_data *sd =3D NULL; - struct bfq_group *bfqg =3D NULL; - struct bfq_data *bfqd =3D NULL; -#endif =20 node =3D bfq_find_deepest(&entity->rb_node); bfq_extract(&st->active, entity); =20 if (node) bfq_update_active_tree(node); - -#ifdef CONFIG_BFQ_GROUP_IOSCHED - sd =3D entity->sched_data; - bfqg =3D container_of(sd, struct bfq_group, sched_data); - bfqd =3D (struct bfq_data *)bfqg->bfqd; -#endif if (bfqq) list_del(&bfqq->bfqq_list); -#ifdef CONFIG_BFQ_GROUP_IOSCHED - if (bfqg !=3D bfqd->root_group) - bfqg->active_entities--; -#endif + + bfq_dec_active_entities(entity); } =20 /** --=20 2.31.1 From nobody Tue May 21 04:49:05 2024 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 B425AC433EF for ; Sat, 28 May 2022 09:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355850AbiE1Jq5 (ORCPT ); Sat, 28 May 2022 05:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239735AbiE1Jqe (ORCPT ); Sat, 28 May 2022 05:46:34 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0126465A0; Sat, 28 May 2022 02:46:33 -0700 (PDT) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4L9Gx46dW0z1JCSZ; Sat, 28 May 2022 17:44:56 +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:46:31 +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:30 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v3 4/6] block, bfq: don't declare 'bfqd' as type 'void *' in bfq_group Date: Sat, 28 May 2022 17:59:56 +0800 Message-ID: <20220528095958.270455-5-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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Prevent unnecessary format conversion for bfqg->bfqd in multiple places. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara Acked-by: Paolo Valente --- block/bfq-cgroup.c | 2 +- block/bfq-iosched.h | 2 +- block/bfq-wf2q.c | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 4d516879d9fa..b4e39ab4ad17 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -224,7 +224,7 @@ void bfqg_stats_update_io_add(struct bfq_group *bfqg, s= truct bfq_queue *bfqq, { blkg_rwstat_add(&bfqg->stats.queued, op, 1); bfqg_stats_end_empty_time(&bfqg->stats); - if (!(bfqq =3D=3D ((struct bfq_data *)bfqg->bfqd)->in_service_queue)) + if (!(bfqq =3D=3D bfqg->bfqd->in_service_queue)) bfqg_stats_set_start_group_wait_time(bfqg, bfqq_group(bfqq)); } =20 diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index ecca2c0570ea..c6109512503b 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -895,7 +895,7 @@ struct bfq_group { struct bfq_entity entity; struct bfq_sched_data sched_data; =20 - void *bfqd; + struct bfq_data *bfqd; =20 struct bfq_queue *async_bfqq[2][IOPRIO_NR_LEVELS]; struct bfq_queue *async_idle_bfqq; diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 643e57ee3e64..26ab9ba6e5a3 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -236,9 +236,8 @@ static void bfq_inc_active_entities(struct bfq_entity *= entity) { struct bfq_sched_data *sd =3D entity->sched_data; struct bfq_group *bfqg =3D container_of(sd, struct bfq_group, sched_data); - struct bfq_data *bfqd =3D (struct bfq_data *)bfqg->bfqd; =20 - if (bfqg !=3D bfqd->root_group) + if (bfqg !=3D bfqg->bfqd->root_group) bfqg->active_entities++; } =20 @@ -246,9 +245,8 @@ static void bfq_dec_active_entities(struct bfq_entity *= entity) { struct bfq_sched_data *sd =3D entity->sched_data; struct bfq_group *bfqg =3D container_of(sd, struct bfq_group, sched_data); - struct bfq_data *bfqd =3D (struct bfq_data *)bfqg->bfqd; =20 - if (bfqg !=3D bfqd->root_group) + if (bfqg !=3D bfqg->bfqd->root_group) bfqg->active_entities--; } =20 @@ -745,7 +743,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree= *old_st, else { sd =3D entity->my_sched_data; bfqg =3D container_of(sd, struct bfq_group, sched_data); - bfqd =3D (struct bfq_data *)bfqg->bfqd; + bfqd =3D bfqg->bfqd; } #endif =20 --=20 2.31.1 From nobody Tue May 21 04:49:05 2024 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 E9B4EC433F5 for ; Sat, 28 May 2022 09:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355422AbiE1JrF (ORCPT ); Sat, 28 May 2022 05:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240405AbiE1Jqe (ORCPT ); Sat, 28 May 2022 05:46:34 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D48D365AD; Sat, 28 May 2022 02:46:33 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4L9Gym6v3HzDqS0; Sat, 28 May 2022 17:46:24 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500016.china.huawei.com (7.221.188.220) 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:31 +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:31 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v3 5/6] block, bfq: cleanup bfq_activate_requeue_entity() Date: Sat, 28 May 2022 17:59:57 +0800 Message-ID: <20220528095958.270455-6-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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Just make the code a litter cleaner by removing the unnecessary variable 'sd'. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara Acked-by: Paolo Valente --- block/bfq-wf2q.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 26ab9ba6e5a3..117d38ab0b30 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1089,12 +1089,12 @@ static void __bfq_requeue_entity(struct bfq_entity = *entity) } =20 static void __bfq_activate_requeue_entity(struct bfq_entity *entity, - struct bfq_sched_data *sd, bool non_blocking_wait_rq) { struct bfq_service_tree *st =3D bfq_entity_service_tree(entity); =20 - if (sd->in_service_entity =3D=3D entity || entity->tree =3D=3D &st->activ= e) + if (entity->sched_data->in_service_entity =3D=3D entity || + entity->tree =3D=3D &st->active) /* * in service or already queued on the active tree, * requeue or reposition @@ -1126,14 +1126,10 @@ static void bfq_activate_requeue_entity(struct bfq_= entity *entity, bool non_blocking_wait_rq, bool requeue, bool expiration) { - struct bfq_sched_data *sd; - for_each_entity(entity) { - sd =3D entity->sched_data; - __bfq_activate_requeue_entity(entity, sd, non_blocking_wait_rq); - - if (!bfq_update_next_in_service(sd, entity, expiration) && - !requeue) + __bfq_activate_requeue_entity(entity, non_blocking_wait_rq); + if (!bfq_update_next_in_service(entity->sched_data, entity, + expiration) && !requeue) break; } } --=20 2.31.1 From nobody Tue May 21 04:49:05 2024 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 118F8C433F5 for ; Sat, 28 May 2022 09:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233365AbiE1JrR (ORCPT ); Sat, 28 May 2022 05:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241279AbiE1Jqf (ORCPT ); Sat, 28 May 2022 05:46:35 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42FE465D3; Sat, 28 May 2022 02:46:34 -0700 (PDT) Received: from kwepemi500015.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4L9Gxh3NvrzjX0P; Sat, 28 May 2022 17:45:28 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500015.china.huawei.com (7.221.188.92) 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:32 +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:31 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH -next v3 6/6] block, bfq: remove dead code for updating 'rq_in_driver' Date: Sat, 28 May 2022 17:59:58 +0800 Message-ID: <20220528095958.270455-7-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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Such code are not even compiled since they are inside marco "#if 0". Signed-off-by: Yu Kuai Reviewed-by: Jan Kara Acked-by: Paolo Valente --- block/bfq-iosched.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 8c7020f8cdf2..79e6a60d61d8 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2321,22 +2321,6 @@ static sector_t get_sdist(sector_t last_pos, struct = request *rq) return 0; } =20 -#if 0 /* Still not clear if we can do without next two functions */ -static void bfq_activate_request(struct request_queue *q, struct request *= rq) -{ - struct bfq_data *bfqd =3D q->elevator->elevator_data; - - bfqd->rq_in_driver++; -} - -static void bfq_deactivate_request(struct request_queue *q, struct request= *rq) -{ - struct bfq_data *bfqd =3D q->elevator->elevator_data; - - bfqd->rq_in_driver--; -} -#endif - static void bfq_remove_request(struct request_queue *q, struct request *rq) { --=20 2.31.1