Three small block layer patches
Subsystems (2)
v3 cover Three small block layer patches
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(-)
PATCH v3 1/3 blk-iocost: Simplify ioc_rqos_done()
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.
--- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-iocost.c +1 -1
@@ -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 ;
PATCH v3 2/3 block: Rename a blk_mq_map_queue() argument
In reply to Bart Van AsscheBefore 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.
--- block/blk-mq.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
block/blk-mq.h +6 -6
@@ -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)]; }/*
PATCH v3 3/3 block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
In reply to Bart Van AsscheSince 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.
--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
@@ -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;
Re: [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
Quoted 10 lines · Bart Van Assche
Since the introduction of
blk_mq_get_hctx_type()the operation type in the second argument ofblk_mq_get_hctx_type()matters. The introduction ofblk_mq_get_hctx_type()causedblk_mq_get_sq_hctx()to select a hardware queue of typeHCTX_TYPE_READinstead ofHCTX_TYPE_DEFAULT. Switch to hardware queue typeHCTX_TYPE_DEFAULTsinceHCTX_TYPE_READshould only be used for read requests.Cc Ming Lei <[email protected]>Cc Christoph Hellwig <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Thanks,
Ming
Re: [PATCH v3 3/3] block: Make blk_mq_get_sq_hctx() select the proper hardware queue type
In reply to Bart Van AsscheLooks good:
Quoted 8 lines · Bart Van Assche
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,
Signature · 1 line
Jens Axboe