diff mbox series

[v9,02/17] block: Only use write locking if necessary

Message ID 20230816195447.3703954-3-bvanassche@acm.org (mailing list archive)
State Superseded
Headers show
Series Improve performance for zoned UFS devices | expand

Commit Message

Bart Van Assche Aug. 16, 2023, 7:53 p.m. UTC
Make blk_req_needs_zone_write_lock() return false if
q->limits.use_zone_write_lock is false. Inline this function because it
is short and because it is called from the hot path of the mq-deadline
I/O scheduler.

Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-zoned.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Damien Le Moal Aug. 17, 2023, 11:01 a.m. UTC | #1
On 8/17/23 04:53, Bart Van Assche wrote:
> Make blk_req_needs_zone_write_lock() return false if
> q->limits.use_zone_write_lock is false. Inline this function because it
> is short and because it is called from the hot path of the mq-deadline
> I/O scheduler.

Your are not actually inlining the function. Did you forget to move it to
blkdev.h ?

Otherwise, the change looks OK.

> 
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/blk-zoned.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 112620985bff..d8a80cce832f 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -53,11 +53,16 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
>  EXPORT_SYMBOL_GPL(blk_zone_cond_str);
>  
>  /*
> - * Return true if a request is a write requests that needs zone write locking.
> + * Return true if a request is a write request that needs zone write locking.
>   */
>  bool blk_req_needs_zone_write_lock(struct request *rq)
>  {
> -	if (!rq->q->disk->seq_zones_wlock)
> +	struct request_queue *q = rq->q;
> +
> +	if (!q->limits.use_zone_write_lock)
> +		return false;
> +
> +	if (!q->disk->seq_zones_wlock)
>  		return false;
>  
>  	return blk_rq_is_seq_zoned_write(rq);
Bart Van Assche Aug. 17, 2023, 2:21 p.m. UTC | #2
On 8/17/23 04:01, Damien Le Moal wrote:
> On 8/17/23 04:53, Bart Van Assche wrote:
>> Make blk_req_needs_zone_write_lock() return false if
>> q->limits.use_zone_write_lock is false. Inline this function because it
>> is short and because it is called from the hot path of the mq-deadline
>> I/O scheduler.
> 
> Your are not actually inlining the function. Did you forget to move it to
> blkdev.h ?

I considered inlining but eventually decided not to inline 
blk_req_needs_zone_write_lock(). I will update the patch description.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 112620985bff..d8a80cce832f 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -53,11 +53,16 @@  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
 EXPORT_SYMBOL_GPL(blk_zone_cond_str);
 
 /*
- * Return true if a request is a write requests that needs zone write locking.
+ * Return true if a request is a write request that needs zone write locking.
  */
 bool blk_req_needs_zone_write_lock(struct request *rq)
 {
-	if (!rq->q->disk->seq_zones_wlock)
+	struct request_queue *q = rq->q;
+
+	if (!q->limits.use_zone_write_lock)
+		return false;
+
+	if (!q->disk->seq_zones_wlock)
 		return false;
 
 	return blk_rq_is_seq_zoned_write(rq);