[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221101093417.10540-16-shikemeng@huawei.com>
Date: Tue, 1 Nov 2022 17:34:12 +0800
From: Kemeng Shi <shikemeng@...wei.com>
To: <paolo.valente@...aro.org>, <axboe@...nel.dk>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<shikemeng@...wei.com>
Subject: [PATCH 15/20] block, bfq: some cleanups for function bfq_pos_tree_add_move
There are three cleanups in this patch:
1. The oom_bfqq is never inserted to tree, so return immediately for
oom_bfqq before unnecessary NULL check of bfqq->pos_root.
2. Only set bfqq->pos_root after bfq_rq_pos_tree_lookup successes rather
than set bfqq->pos_root unconditionally and reset to NULL if
bfq_rq_pos_tree_lookup fails.
3. Remove unnecessary local variable __bfqq which is only used to check
return value of bfq_rq_pos_tree_lookup.
Signed-off-by: Kemeng Shi <shikemeng@...wei.com>
---
block/bfq-iosched.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 776951156fbc..dd9a51255a0f 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -758,17 +758,16 @@ void __cold
bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq)
{
struct rb_node **p, *parent;
- struct bfq_queue *__bfqq;
+
+ /* oom_bfqq does not participate in queue merging */
+ if (bfqq == &bfqd->oom_bfqq)
+ return;
if (bfqq->pos_root) {
rb_erase(&bfqq->pos_node, bfqq->pos_root);
bfqq->pos_root = NULL;
}
- /* oom_bfqq does not participate in queue merging */
- if (bfqq == &bfqd->oom_bfqq)
- return;
-
/*
* bfqq cannot be merged any longer (see comments in
* bfq_setup_cooperator): no point in adding bfqq into the
@@ -782,14 +781,13 @@ bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq)
if (!bfqq->next_rq)
return;
+ if (bfq_rq_pos_tree_lookup(bfqd, &bfqq_group(bfqq)->rq_pos_tree,
+ blk_rq_pos(bfqq->next_rq), &parent, &p))
+ return;
+
bfqq->pos_root = &bfqq_group(bfqq)->rq_pos_tree;
- __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root,
- blk_rq_pos(bfqq->next_rq), &parent, &p);
- if (!__bfqq) {
- rb_link_node(&bfqq->pos_node, parent, p);
- rb_insert_color(&bfqq->pos_node, bfqq->pos_root);
- } else
- bfqq->pos_root = NULL;
+ rb_link_node(&bfqq->pos_node, parent, p);
+ rb_insert_color(&bfqq->pos_node, bfqq->pos_root);
}
/*
--
2.30.0
Powered by blists - more mailing lists