* [PATCH] block: Remove redundant hctx pointer dereferencing operation
@ 2025-10-16 13:16 chengkaitao
2025-10-17 6:27 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: chengkaitao @ 2025-10-16 13:16 UTC (permalink / raw)
To: axboe, dlemoal, yukuai3; +Cc: linux-block, linux-kernel, Chengkaitao
From: Chengkaitao <chengkaitao@kylinos.cn>
The {*q = hctx->queue} statement in the dd_insert_requestfunction is
redundant. This patch removes the operation and modifies the function's
formal parameters accordingly. To maintain code formatting consistency,
similar modifications are applied to bfq_insert_request. Changing both
functions' parameters to request_queue also improves logical consistency.
Signed-off-by: Chengkaitao <chengkaitao@kylinos.cn>
---
block/bfq-iosched.c | 5 ++---
block/mq-deadline.c | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 50e51047e1fe..b0e2fe645c3e 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -6233,10 +6233,9 @@ static inline void bfq_update_insert_stats(struct request_queue *q,
static struct bfq_queue *bfq_init_rq(struct request *rq);
-static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
+static void bfq_insert_request(struct request_queue *q, struct request *rq,
blk_insert_t flags)
{
- struct request_queue *q = hctx->queue;
struct bfq_data *bfqd = q->elevator->elevator_data;
struct bfq_queue *bfqq;
bool idle_timer_disabled = false;
@@ -6298,7 +6297,7 @@ static void bfq_insert_requests(struct blk_mq_hw_ctx *hctx,
rq = list_first_entry(list, struct request, queuelist);
list_del_init(&rq->queuelist);
- bfq_insert_request(hctx, rq, flags);
+ bfq_insert_request(hctx->queue, rq, flags);
}
}
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index b9b7cdf1d3c9..86b888681552 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -646,10 +646,9 @@ static bool dd_bio_merge(struct request_queue *q, struct bio *bio,
/*
* add rq to rbtree and fifo
*/
-static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
+static void dd_insert_request(struct request_queue *q, struct request *rq,
blk_insert_t flags, struct list_head *free)
{
- struct request_queue *q = hctx->queue;
struct deadline_data *dd = q->elevator->elevator_data;
const enum dd_data_dir data_dir = rq_data_dir(rq);
u16 ioprio = req_get_ioprio(rq);
@@ -707,7 +706,7 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx,
rq = list_first_entry(list, struct request, queuelist);
list_del_init(&rq->queuelist);
- dd_insert_request(hctx, rq, flags, &free);
+ dd_insert_request(q, rq, flags, &free);
}
spin_unlock(&dd->lock);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] block: Remove redundant hctx pointer dereferencing operation
2025-10-16 13:16 [PATCH] block: Remove redundant hctx pointer dereferencing operation chengkaitao
@ 2025-10-17 6:27 ` Christoph Hellwig
2025-10-17 6:54 ` Tao pilgrim
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2025-10-17 6:27 UTC (permalink / raw)
To: chengkaitao
Cc: axboe, dlemoal, yukuai3, linux-block, linux-kernel, Chengkaitao
On Thu, Oct 16, 2025 at 09:16:51PM +0800, chengkaitao wrote:
> From: Chengkaitao <chengkaitao@kylinos.cn>
>
> The {*q = hctx->queue} statement in the dd_insert_requestfunction is
> redundant. This patch removes the operation and modifies the function's
> formal parameters accordingly.
What formal parameters?
Basically you're passing a pointless extra argument instead of deriving
it locally. Why would you do that?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] block: Remove redundant hctx pointer dereferencing operation
2025-10-17 6:27 ` Christoph Hellwig
@ 2025-10-17 6:54 ` Tao pilgrim
0 siblings, 0 replies; 3+ messages in thread
From: Tao pilgrim @ 2025-10-17 6:54 UTC (permalink / raw)
To: Christoph Hellwig
Cc: axboe, dlemoal, yukuai3, linux-block, linux-kernel, Chengkaitao
On Fri, Oct 17, 2025 at 2:27 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Thu, Oct 16, 2025 at 09:16:51PM +0800, chengkaitao wrote:
> > From: Chengkaitao <chengkaitao@kylinos.cn>
> >
> > The {*q = hctx->queue} statement in the dd_insert_requestfunction is
> > redundant. This patch removes the operation and modifies the function's
> > formal parameters accordingly.
>
> What formal parameters?
>
> Basically you're passing a pointless extra argument instead of deriving
> it locally. Why would you do that?
The value of 'hctx->queue' is already stored in '*q' within dd_insert_requests,
we can directly reuse the result instead of dereferencing hctx again in the
dd_insert_request function. We can eliminate an LDR instruction.
--
Yours,
Kaitao Cheng
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-17 6:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 13:16 [PATCH] block: Remove redundant hctx pointer dereferencing operation chengkaitao
2025-10-17 6:27 ` Christoph Hellwig
2025-10-17 6:54 ` Tao pilgrim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox