All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Jaegeuk Kim <jaegeuk@kernel.org>, Ming Lei <ming.lei@redhat.com>
Subject: Re: [PATCH v4 3/7] block/mq-deadline: Only use zone locking if necessary
Date: Thu, 27 Jul 2023 09:09:34 +0900	[thread overview]
Message-ID: <53514e4d-e75f-3bf0-efa2-b162b6ac73a2@kernel.org> (raw)
In-Reply-To: <20230726193440.1655149-4-bvanassche@acm.org>

On 7/27/23 04:34, Bart Van Assche wrote:
> Measurements have shown that limiting the queue depth to one for zoned

to one -> to one per zone

> writes has a significant negative performance impact on zoned UFS devices.
> Hence this patch that disables zone locking by the mq-deadline scheduler
> if zoned writes are submitted in order and if the storage controller

The "submitted in order" is actually never checked. So let's not use this in
this explanation.

> preserves the command order. This patch is based on the following
> assumptions:
> - It happens infrequently that zoned write requests are reordered by the
>   block layer.
> - The I/O priority of all write requests is the same per zone.
> - Either no I/O scheduler is used or an I/O scheduler is used that
>   submits write requests per zone in LBA order.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Cc: Ming Lei <ming.lei@redhat.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/mq-deadline.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/block/mq-deadline.c b/block/mq-deadline.c
> index 02a916ba62ee..9a64577fe942 100644
> --- a/block/mq-deadline.c
> +++ b/block/mq-deadline.c
> @@ -338,6 +338,17 @@ static struct request *deadline_skip_seq_writes(struct deadline_data *dd,
>  	return rq;
>  }
>  
> +/*
> + * Use write locking if either QUEUE_FLAG_NO_ZONE_WRITE_LOCK or
> + * REQ_NO_ZONE_WRITE_LOCK has not been set. Not using zone write locking is
> + * only safe if the submitter allocates and submit requests in LBA order per
> + * zone and if the block driver preserves the request order.
> + */
> +static bool dd_use_write_locking(struct request *rq)

Nit: maybe rename this to dd_use_zone_write_locking() to be clear this is for
zoned devices only ?

> +{
> +	return blk_queue_is_zoned(rq->q) && !blk_no_zone_write_lock(rq);
> +}
> +
>  /*
>   * For the specified data direction, return the next request to
>   * dispatch using arrival ordered lists.
> @@ -353,7 +364,7 @@ deadline_fifo_request(struct deadline_data *dd, struct dd_per_prio *per_prio,
>  		return NULL;
>  
>  	rq = rq_entry_fifo(per_prio->fifo_list[data_dir].next);
> -	if (data_dir == DD_READ || !blk_queue_is_zoned(rq->q))
> +	if (data_dir == DD_READ || !dd_use_write_locking(rq))
>  		return rq;
>  
>  	/*
> @@ -398,7 +409,7 @@ deadline_next_request(struct deadline_data *dd, struct dd_per_prio *per_prio,
>  	if (!rq)
>  		return NULL;
>  
> -	if (data_dir == DD_READ || !blk_queue_is_zoned(rq->q))
> +	if (data_dir == DD_READ || !dd_use_write_locking(rq))
>  		return rq;
>  
>  	/*
> @@ -526,8 +537,9 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd,
>  	}
>  
>  	/*
> -	 * For a zoned block device, if we only have writes queued and none of
> -	 * them can be dispatched, rq will be NULL.
> +	 * For a zoned block device that requires write serialization, if we
> +	 * only have writes queued and none of them can be dispatched, rq will
> +	 * be NULL.
>  	 */
>  	if (!rq)
>  		return NULL;
> @@ -552,7 +564,8 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd,
>  	/*
>  	 * If the request needs its target zone locked, do it.
>  	 */
> -	blk_req_zone_write_lock(rq);
> +	if (dd_use_write_locking(rq))
> +		blk_req_zone_write_lock(rq);
>  	rq->rq_flags |= RQF_STARTED;
>  	return rq;
>  }
> @@ -933,7 +946,7 @@ static void dd_finish_request(struct request *rq)
>  
>  	atomic_inc(&per_prio->stats.completed);
>  
> -	if (blk_queue_is_zoned(q)) {
> +	if (dd_use_write_locking(rq)) {
>  		unsigned long flags;
>  
>  		spin_lock_irqsave(&dd->zone_lock, flags);

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2023-07-27  0:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26 19:34 [PATCH v4 0/7] Improve the performance of F2FS on zoned UFS Bart Van Assche
2023-07-26 19:34 ` [PATCH v4 1/7] block: Introduce the flag QUEUE_FLAG_NO_ZONE_WRITE_LOCK Bart Van Assche
2023-07-26 23:49   ` Damien Le Moal
2023-07-27  0:54   ` Chaitanya Kulkarni
2023-07-27 20:20     ` Bart Van Assche
2023-07-27 20:52       ` Chaitanya Kulkarni
2023-07-27 10:59   ` Nitesh Shetty
2023-07-27 14:43     ` Bart Van Assche
2023-07-27 19:06       ` Nitesh Shetty
2023-07-26 19:34 ` [PATCH v4 2/7] block: Introduce the flag REQ_NO_ZONE_WRITE_LOCK Bart Van Assche
2023-07-27  0:03   ` Damien Le Moal
2023-07-26 19:34 ` [PATCH v4 3/7] block/mq-deadline: Only use zone locking if necessary Bart Van Assche
2023-07-27  0:09   ` Damien Le Moal [this message]
2023-07-26 19:34 ` [PATCH v4 4/7] block/null_blk: Support disabling zone write locking Bart Van Assche
2023-07-27  0:04   ` Damien Le Moal
2023-07-27  0:36   ` Chaitanya Kulkarni
2023-07-27 20:26     ` Bart Van Assche
2023-07-27 19:02   ` Nitesh Shetty
2023-07-26 19:34 ` [PATCH v4 5/7] scsi: Retry unaligned zoned writes Bart Van Assche
2023-07-27  0:33   ` Damien Le Moal
2023-07-27  1:03     ` Bart Van Assche
2023-07-27  1:09       ` Damien Le Moal
2023-07-27 14:53         ` Bart Van Assche
2023-07-27 20:57     ` Bart Van Assche
2023-07-26 19:34 ` [PATCH v4 6/7] scsi: ufs: Disable zone write locking Bart Van Assche
2023-07-27 21:55   ` kernel test robot
2023-07-26 19:34 ` [PATCH v4 7/7] fs/f2fs: " Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53514e4d-e75f-3bf0-efa2-b162b6ac73a2@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=jaegeuk@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.