public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] block/mq-deadline: Remove redundant hctx pointer dereferencing operation
@ 2025-11-18  1:25 chengkaitao
  2025-11-18  6:08 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: chengkaitao @ 2025-11-18  1:25 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Chengkaitao

From: Chengkaitao <chengkaitao@kylinos.cn>

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. This
patch removes the redundant operation and modifies the function's
parameters accordingly. We can eliminate an LDR instruction.

Signed-off-by: Chengkaitao <chengkaitao@kylinos.cn>
---
v2:
  1. Remove the changes related to bfq-iosched.
  2. Add more commit message.
v1:
  https://lore.kernel.org/all/20251016131651.83182-1-pilgrimtao@gmail.com/
---
 block/mq-deadline.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index 3e741d33142d..5007d811a738 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -633,10 +633,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);
@@ -694,7 +693,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 v2] block/mq-deadline: Remove redundant hctx pointer dereferencing operation
  2025-11-18  1:25 [PATCH v2] block/mq-deadline: Remove redundant hctx pointer dereferencing operation chengkaitao
@ 2025-11-18  6:08 ` Christoph Hellwig
  2025-11-18  7:24   ` Tao pilgrim
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2025-11-18  6:08 UTC (permalink / raw)
  To: chengkaitao; +Cc: axboe, linux-block, linux-kernel, Chengkaitao

On Tue, Nov 18, 2025 at 09:25:39AM +0800, chengkaitao wrote:
> From: Chengkaitao <chengkaitao@kylinos.cn>
> 
> 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. This
> patch removes the redundant operation and modifies the function's
> parameters accordingly. We can eliminate an LDR instruction.

But you pass additional parameters on the stack.  Aka you're causing
churn here with bogus arguments.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] block/mq-deadline: Remove redundant hctx pointer dereferencing operation
  2025-11-18  6:08 ` Christoph Hellwig
@ 2025-11-18  7:24   ` Tao pilgrim
  0 siblings, 0 replies; 3+ messages in thread
From: Tao pilgrim @ 2025-11-18  7:24 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, linux-block, linux-kernel, Chengkaitao

On Tue, Nov 18, 2025 at 2:08 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Tue, Nov 18, 2025 at 09:25:39AM +0800, chengkaitao wrote:
> > From: Chengkaitao <chengkaitao@kylinos.cn>
> >
> > 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. This
> > patch removes the redundant operation and modifies the function's
> > parameters accordingly. We can eliminate an LDR instruction.
>
> But you pass additional parameters on the stack.  Aka you're causing
> churn here with bogus arguments.

This patch replaces "struct blk_mq_hw_ctx *hctx" with "struct request_queue *q"
without introducing additional parameters. The total number of parameters for
the dd_insert_request function remains unchanged.

-- 
Yours,
Chengkaitao

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-18  7:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18  1:25 [PATCH v2] block/mq-deadline: Remove redundant hctx pointer dereferencing operation chengkaitao
2025-11-18  6:08 ` Christoph Hellwig
2025-11-18  7:24   ` Tao pilgrim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox