All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Adam Manzanares <adam.manzanares@wdc.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Damien Le Moal <damien.lemoal@wdc.com>,
	Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 7/9] block/mq-deadline: Reserve 25% of tags for synchronous requests
Date: Wed, 26 May 2021 18:01:32 -0700	[thread overview]
Message-ID: <20210527010134.32448-8-bvanassche@acm.org> (raw)
In-Reply-To: <20210527010134.32448-1-bvanassche@acm.org>

For interactive workloads it is important that synchronous requests are
not delayed. Hence reserve 25% of tags for synchronous requests. This patch
still allows asynchronous requests to fill the hardware queues since
blk_mq_init_sched() makes sure that the number of scheduler requests is the
double of the hardware queue depth. From blk_mq_init_sched():

	q->nr_requests = 2 * min_t(unsigned int, q->tag_set->queue_depth,
				   BLKDEV_MAX_RQ);

Cc: Damien Le Moal <damien.lemoal@wdc.com>
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 | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index 2ab844a4b6b5..81f487d77e09 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -69,6 +69,7 @@ struct deadline_data {
 	int fifo_batch;
 	int writes_starved;
 	int front_merges;
+	u32 async_depth;
 
 	spinlock_t lock;
 	spinlock_t zone_lock;
@@ -399,6 +400,38 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
 	return rq;
 }
 
+static void dd_limit_depth(unsigned int op, struct blk_mq_alloc_data *data)
+{
+	struct deadline_data *dd = data->q->elevator->elevator_data;
+
+	/* Do not throttle synchronous reads. */
+	if (op_is_sync(op) && !op_is_write(op))
+		return;
+
+	/*
+	 * Throttle asynchronous requests and writes such that these requests
+	 * do not block the allocation of synchronous requests.
+	 */
+	data->shallow_depth = dd->async_depth;
+}
+
+static void dd_depth_updated(struct blk_mq_hw_ctx *hctx)
+{
+	struct request_queue *q = hctx->queue;
+	struct deadline_data *dd = q->elevator->elevator_data;
+	struct blk_mq_tags *tags = hctx->sched_tags;
+
+	dd->async_depth = 3 * q->nr_requests / 4;
+
+	sbitmap_queue_min_shallow_depth(tags->bitmap_tags, dd->async_depth);
+}
+
+static int dd_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx)
+{
+	dd_depth_updated(hctx);
+	return 0;
+}
+
 static void dd_exit_sched(struct elevator_queue *e)
 {
 	struct deadline_data *dd = e->elevator_data;
@@ -744,6 +777,15 @@ static int deadline_starved_show(void *data, struct seq_file *m)
 	return 0;
 }
 
+static int dd_async_depth_show(void *data, struct seq_file *m)
+{
+	struct request_queue *q = data;
+	struct deadline_data *dd = q->elevator->elevator_data;
+
+	seq_printf(m, "%u\n", dd->async_depth);
+	return 0;
+}
+
 static void *deadline_dispatch_start(struct seq_file *m, loff_t *pos)
 	__acquires(&dd->lock)
 {
@@ -786,6 +828,7 @@ static const struct blk_mq_debugfs_attr deadline_queue_debugfs_attrs[] = {
 	DEADLINE_QUEUE_DDIR_ATTRS(write),
 	{"batching", 0400, deadline_batching_show},
 	{"starved", 0400, deadline_starved_show},
+	{"async_depth", 0400, dd_async_depth_show},
 	{"dispatch", 0400, .seq_ops = &deadline_dispatch_seq_ops},
 	{},
 };
@@ -794,6 +837,8 @@ static const struct blk_mq_debugfs_attr deadline_queue_debugfs_attrs[] = {
 
 static struct elevator_type mq_deadline = {
 	.ops = {
+		.depth_updated		= dd_depth_updated,
+		.limit_depth		= dd_limit_depth,
 		.insert_requests	= dd_insert_requests,
 		.dispatch_request	= dd_dispatch_request,
 		.prepare_request	= dd_prepare_request,
@@ -807,6 +852,7 @@ static struct elevator_type mq_deadline = {
 		.has_work		= dd_has_work,
 		.init_sched		= dd_init_sched,
 		.exit_sched		= dd_exit_sched,
+		.init_hctx		= dd_init_hctx,
 	},
 
 #ifdef CONFIG_BLK_DEBUG_FS

  parent reply	other threads:[~2021-05-27  1:02 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27  1:01 [PATCH 0/9] Improve I/O priority support Bart Van Assche
2021-05-27  1:01 ` [PATCH 1/9] block/mq-deadline: Add several comments Bart Van Assche
2021-05-27  3:03   ` Damien Le Moal
2021-05-27  6:45   ` Hannes Reinecke
2021-05-27 19:30     ` Bart Van Assche
2021-05-27  8:43   ` Johannes Thumshirn
2021-05-27 15:13   ` Himanshu Madhani
2021-05-27  1:01 ` [PATCH 2/9] block/mq-deadline: Add two lockdep_assert_held() statements Bart Van Assche
2021-05-27  2:25   ` Chaitanya Kulkarni
2021-05-27  3:09   ` Damien Le Moal
2021-05-27  6:46   ` Hannes Reinecke
2021-05-27  8:44   ` Johannes Thumshirn
2021-05-27 15:14   ` Himanshu Madhani
2021-05-27  1:01 ` [PATCH 3/9] block/mq-deadline: Remove two local variables Bart Van Assche
2021-05-27  2:26   ` Chaitanya Kulkarni
2021-05-27  3:11   ` Damien Le Moal
2021-05-27  6:46   ` Hannes Reinecke
2021-05-27  8:44   ` Johannes Thumshirn
2021-05-27 15:15   ` Himanshu Madhani
2021-05-27  1:01 ` [PATCH 4/9] block/mq-deadline: Rename dd_init_queue() and dd_exit_queue() Bart Van Assche
2021-05-27  2:27   ` Chaitanya Kulkarni
2021-05-27  3:13   ` Damien Le Moal
2021-05-27 19:33     ` Bart Van Assche
2021-05-27  6:47   ` Hannes Reinecke
2021-05-27  8:44   ` Johannes Thumshirn
2021-05-27 15:16   ` Himanshu Madhani
2021-05-27  1:01 ` [PATCH 5/9] block/mq-deadline: Improve compile-time argument checking Bart Van Assche
2021-05-27  2:28   ` Chaitanya Kulkarni
2021-05-27  3:24   ` Damien Le Moal
2021-05-27 19:38     ` Bart Van Assche
2021-05-28  1:42       ` Damien Le Moal
2021-05-27  6:48   ` Hannes Reinecke
2021-05-27  8:49   ` Johannes Thumshirn
2021-05-27 15:19   ` Himanshu Madhani
2021-05-27  1:01 ` [PATCH 6/9] block/mq-deadline: Reduce the read expiry time for non-rotational media Bart Van Assche
2021-05-27  2:30   ` Chaitanya Kulkarni
2021-05-27  3:27   ` Damien Le Moal
2021-05-27 19:43     ` Bart Van Assche
2021-05-27  6:52   ` Hannes Reinecke
2021-05-27 15:20   ` Himanshu Madhani
2021-05-27  1:01 ` Bart Van Assche [this message]
2021-05-27  3:33   ` [PATCH 7/9] block/mq-deadline: Reserve 25% of tags for synchronous requests Damien Le Moal
2021-05-27 20:00     ` Bart Van Assche
2021-05-27  6:54   ` Hannes Reinecke
2021-05-27 19:55     ` Bart Van Assche
2021-05-27  1:01 ` [PATCH 8/9] block/mq-deadline: Add I/O priority support Bart Van Assche
2021-05-27  3:48   ` Damien Le Moal
2021-05-27 20:12     ` Bart Van Assche
2021-05-27  7:07   ` Hannes Reinecke
2021-05-27 20:23     ` Bart Van Assche
2021-05-28  1:40       ` Damien Le Moal
2021-05-27  1:01 ` [PATCH 9/9] block/mq-deadline: Add cgroup support Bart Van Assche
2021-05-27  7:09   ` Hannes Reinecke
2021-05-27  6:25 ` [PATCH 0/9] Improve I/O priority support Wang Jianchao
2021-05-27  8:05   ` Wang Jianchao
2021-05-27 18:40     ` Bart Van Assche
2021-05-28  2:05       ` Wang Jianchao
2021-05-28  8:43         ` Paolo Valente
2021-05-28 16:28         ` Bart Van Assche
2021-05-27  8:56 ` Johannes Thumshirn
2021-05-27 17:23   ` Chaitanya Kulkarni
2021-05-27 19:00     ` Bart Van Assche
2021-05-27 17:58 ` Adam Manzanares
2021-05-27 18:53   ` Bart Van Assche
2021-05-27 22:45     ` Adam Manzanares

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=20210527010134.32448-8-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=adam.manzanares@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=hch@lst.de \
    --cc=jaegeuk@kernel.org \
    --cc=linux-block@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 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.