All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Three small block layer patches
@ 2022-06-15 22:55 Bart Van Assche
  2022-06-15 22:55 ` [PATCH v3 1/3] blk-iocost: Simplify ioc_rqos_done() Bart Van Assche
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Bart Van Assche @ 2022-06-15 22:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Bart Van Assche

Hi Jens,

These three patches are what I came up with while reading block layer code in
preparation of the patch series for improving zoned write performance.

Please consider this patch series for kernel v5.20.

Thanks,

Bart.

Changes between v2 and v3:
- Explained the "why" of patch 3/3 in its commit message as requested by Jens.

Changes between v1 and v2:
- Modified patch 3/3 as suggested by Ming Lei.

Bart Van Assche (3):
  blk-iocost: Simplify ioc_rqos_done()
  block: Rename a blk_mq_map_queue() argument
  block: Make blk_mq_get_sq_hctx() select the proper hardware queue type

 block/blk-iocost.c |  2 +-
 block/blk-mq.c     |  2 +-
 block/blk-mq.h     | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)


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

* [PATCH v3 1/3] blk-iocost: Simplify ioc_rqos_done()
  2022-06-15 22:55 [PATCH v3 0/3] Three small block layer patches Bart Van Assche
@ 2022-06-15 22:55 ` Bart Van Assche
  2022-06-15 22:55 ` [PATCH v3 2/3] block: Rename a blk_mq_map_queue() argument Bart Van Assche
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2022-06-15 22:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Bart Van Assche, Tejun Heo

Leave out the superfluous "& REQ_OP_MASK" code. The definition of req_op()
shows that that code is superfluous:

 #define req_op(req) ((req)->cmd_flags & REQ_OP_MASK)

Compile-tested only.

Cc: Tejun Heo <tj@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-iocost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 33a11ba971ea..b7082f2aed9c 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2769,7 +2769,7 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
 	if (!ioc->enabled || !rq->alloc_time_ns || !rq->start_time_ns)
 		return;
 
-	switch (req_op(rq) & REQ_OP_MASK) {
+	switch (req_op(rq)) {
 	case REQ_OP_READ:
 		pidx = QOS_RLAT;
 		rw = READ;

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

* [PATCH v3 2/3] block: Rename a blk_mq_map_queue() argument
  2022-06-15 22:55 [PATCH v3 0/3] Three small block layer patches Bart Van Assche
  2022-06-15 22:55 ` [PATCH v3 1/3] blk-iocost: Simplify ioc_rqos_done() Bart Van Assche
@ 2022-06-15 22:55 ` Bart Van Assche
  2022-06-15 22:55 ` [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type Bart Van Assche
  2022-06-16 20:46 ` [PATCH v3 0/3] Three small block layer patches Jens Axboe
  3 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2022-06-15 22:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Bart Van Assche

Before the introduction of blk_mq_get_hctx_type(), blk_mq_map_queue()
only used the flags from its second argument. Since the introduction of
blk_mq_get_hctx_type(), blk_mq_map_queue() uses both the operation and
the flags encoded in that argument. Rename the second argument of
blk_mq_map_queue() to make this clear.

Cc: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-mq.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq.h b/block/blk-mq.h
index 2615bd58bad3..e4c6fe2c8ac8 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -86,16 +86,16 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue_type(struct request_queue *
 	return xa_load(&q->hctx_table, q->tag_set->map[type].mq_map[cpu]);
 }
 
-static inline enum hctx_type blk_mq_get_hctx_type(unsigned int flags)
+static inline enum hctx_type blk_mq_get_hctx_type(unsigned int opf)
 {
 	enum hctx_type type = HCTX_TYPE_DEFAULT;
 
 	/*
 	 * The caller ensure that if REQ_POLLED, poll must be enabled.
 	 */
-	if (flags & REQ_POLLED)
+	if (opf & REQ_POLLED)
 		type = HCTX_TYPE_POLL;
-	else if ((flags & REQ_OP_MASK) == REQ_OP_READ)
+	else if ((opf & REQ_OP_MASK) == REQ_OP_READ)
 		type = HCTX_TYPE_READ;
 	return type;
 }
@@ -103,14 +103,14 @@ static inline enum hctx_type blk_mq_get_hctx_type(unsigned int flags)
 /*
  * blk_mq_map_queue() - map (cmd_flags,type) to hardware queue
  * @q: request queue
- * @flags: request command flags
+ * @opf: operation type (REQ_OP_*) and flags (e.g. REQ_POLLED).
  * @ctx: software queue cpu ctx
  */
 static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
-						     unsigned int flags,
+						     unsigned int opf,
 						     struct blk_mq_ctx *ctx)
 {
-	return ctx->hctxs[blk_mq_get_hctx_type(flags)];
+	return ctx->hctxs[blk_mq_get_hctx_type(opf)];
 }
 
 /*

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

* [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
  2022-06-15 22:55 [PATCH v3 0/3] Three small block layer patches Bart Van Assche
  2022-06-15 22:55 ` [PATCH v3 1/3] blk-iocost: Simplify ioc_rqos_done() Bart Van Assche
  2022-06-15 22:55 ` [PATCH v3 2/3] block: Rename a blk_mq_map_queue() argument Bart Van Assche
@ 2022-06-15 22:55 ` Bart Van Assche
  2022-06-16  1:37   ` Ming Lei
  2022-06-16  6:17   ` Christoph Hellwig
  2022-06-16 20:46 ` [PATCH v3 0/3] Three small block layer patches Jens Axboe
  3 siblings, 2 replies; 7+ messages in thread
From: Bart Van Assche @ 2022-06-15 22:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Bart Van Assche, Ming Lei

Since the introduction of blk_mq_get_hctx_type() the operation type in
the second argument of blk_mq_get_hctx_type() matters. The introduction
of blk_mq_get_hctx_type() caused blk_mq_get_sq_hctx() to select a
hardware queue of type HCTX_TYPE_READ instead of HCTX_TYPE_DEFAULT.
Switch to hardware queue type HCTX_TYPE_DEFAULT since HCTX_TYPE_READ
should only be used for read requests.

Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index e9bf950983c7..7a5558bbc7f6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2168,7 +2168,7 @@ static struct blk_mq_hw_ctx *blk_mq_get_sq_hctx(struct request_queue *q)
 	 * just causes lock contention inside the scheduler and pointless cache
 	 * bouncing.
 	 */
-	struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, 0, ctx);
+	struct blk_mq_hw_ctx *hctx = ctx->hctxs[HCTX_TYPE_DEFAULT];
 
 	if (!blk_mq_hctx_stopped(hctx))
 		return hctx;

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

* Re: [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
  2022-06-15 22:55 ` [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type Bart Van Assche
@ 2022-06-16  1:37   ` Ming Lei
  2022-06-16  6:17   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Ming Lei @ 2022-06-16  1:37 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Christoph Hellwig

On Wed, Jun 15, 2022 at 03:55:49PM -0700, Bart Van Assche wrote:
> Since the introduction of blk_mq_get_hctx_type() the operation type in
> the second argument of blk_mq_get_hctx_type() matters. The introduction
> of blk_mq_get_hctx_type() caused blk_mq_get_sq_hctx() to select a
> hardware queue of type HCTX_TYPE_READ instead of HCTX_TYPE_DEFAULT.
> Switch to hardware queue type HCTX_TYPE_DEFAULT since HCTX_TYPE_READ
> should only be used for read requests.
> 
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks,
Ming


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

* Re: [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
  2022-06-15 22:55 ` [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type Bart Van Assche
  2022-06-16  1:37   ` Ming Lei
@ 2022-06-16  6:17   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2022-06-16  6:17 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Christoph Hellwig, Ming Lei

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 0/3] Three small block layer patches
  2022-06-15 22:55 [PATCH v3 0/3] Three small block layer patches Bart Van Assche
                   ` (2 preceding siblings ...)
  2022-06-15 22:55 ` [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type Bart Van Assche
@ 2022-06-16 20:46 ` Jens Axboe
  3 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2022-06-16 20:46 UTC (permalink / raw)
  To: bvanassche; +Cc: linux-block, Christoph Hellwig

On Wed, 15 Jun 2022 15:55:46 -0700, Bart Van Assche wrote:
> These three patches are what I came up with while reading block layer code in
> preparation of the patch series for improving zoned write performance.
> 
> Please consider this patch series for kernel v5.20.
> 
> Thanks,
> 
> [...]

Applied, thanks!

[1/3] blk-iocost: Simplify ioc_rqos_done()
      (no commit info)
[2/3] block: Rename a blk_mq_map_queue() argument
      (no commit info)
[3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
      (no commit info)

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-06-16 20:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 22:55 [PATCH v3 0/3] Three small block layer patches Bart Van Assche
2022-06-15 22:55 ` [PATCH v3 1/3] blk-iocost: Simplify ioc_rqos_done() Bart Van Assche
2022-06-15 22:55 ` [PATCH v3 2/3] block: Rename a blk_mq_map_queue() argument Bart Van Assche
2022-06-15 22:55 ` [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type Bart Van Assche
2022-06-16  1:37   ` Ming Lei
2022-06-16  6:17   ` Christoph Hellwig
2022-06-16 20:46 ` [PATCH v3 0/3] Three small block layer patches Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.