From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
Jaegeuk Kim <jaegeuk@kernel.org>, Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bvanassche@acm.org>,
Damien Le Moal <dlemoal@kernel.org>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH v7 2/7] block/mq-deadline: Only use zone locking if necessary
Date: Wed, 9 Aug 2023 13:23:43 -0700 [thread overview]
Message-ID: <20230809202355.1171455-3-bvanassche@acm.org> (raw)
In-Reply-To: <20230809202355.1171455-1-bvanassche@acm.org>
Measurements have shown that limiting the queue depth to one per zone for
zoned writes has a significant negative performance impact on zoned UFS
devices. Hence this patch that disables zone locking by the mq-deadline
scheduler if the storage controller 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
serializes write requests per zone.
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/mq-deadline.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index f958e79277b8..cd2504205ff8 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -338,6 +338,16 @@ static struct request *deadline_skip_seq_writes(struct deadline_data *dd,
return rq;
}
+/*
+ * Whether or not to use zone write locking. Not using zone write locking for
+ * sequential write required zones is only safe if the block driver preserves
+ * the request order.
+ */
+static bool dd_use_zone_write_locking(struct request_queue *q)
+{
+ return q->limits.use_zone_write_lock && blk_queue_is_zoned(q);
+}
+
/*
* For the specified data direction, return the next request to
* dispatch using arrival ordered lists.
@@ -353,7 +363,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_zone_write_locking(rq->q))
return rq;
/*
@@ -398,7 +408,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_zone_write_locking(rq->q))
return rq;
/*
@@ -526,8 +536,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 +563,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_zone_write_locking(rq->q))
+ blk_req_zone_write_lock(rq);
rq->rq_flags |= RQF_STARTED;
return rq;
}
@@ -934,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_zone_write_locking(rq->q)) {
unsigned long flags;
spin_lock_irqsave(&dd->zone_lock, flags);
next prev parent reply other threads:[~2023-08-09 20:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 20:23 [PATCH v7 0/7] Improve performance for zoned UFS devices Bart Van Assche
2023-08-09 20:23 ` [PATCH v7 1/7] block: Introduce the use_zone_write_lock member variable Bart Van Assche
2023-08-10 1:33 ` Damien Le Moal
2023-08-10 14:02 ` Bart Van Assche
2023-08-11 0:39 ` Damien Le Moal
2023-08-11 15:41 ` Bart Van Assche
2023-08-12 2:44 ` Damien Le Moal
2023-08-09 20:23 ` Bart Van Assche [this message]
2023-08-10 1:36 ` [PATCH v7 2/7] block/mq-deadline: Only use zone locking if necessary Damien Le Moal
2023-08-10 14:00 ` Bart Van Assche
2023-08-11 0:45 ` Damien Le Moal
2023-08-11 15:49 ` Bart Van Assche
2023-08-12 2:49 ` Damien Le Moal
2023-08-09 20:23 ` [PATCH v7 3/7] scsi: core: Retry unaligned zoned writes Bart Van Assche
2023-08-11 13:29 ` Christoph Hellwig
2023-08-09 20:23 ` [PATCH v7 4/7] scsi: scsi_debug: Support disabling zone write locking Bart Van Assche
2023-08-09 20:23 ` [PATCH v7 5/7] scsi: scsi_debug: Support injecting unaligned write errors Bart Van Assche
2023-08-09 20:23 ` [PATCH v7 6/7] scsi: ufs: Split an if-condition Bart Van Assche
2023-08-09 20:23 ` [PATCH v7 7/7] scsi: ufs: Disable zone write locking 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=20230809202355.1171455-3-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).