All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth
@ 2018-05-09 20:49 Jens Axboe
  2018-05-09 20:49 ` [PATCH 1/7] blk-mq: don't call into depth limiting for reserved tags Jens Axboe
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente

Omar had some valid complaints about the previous patchset, mostly
around the fact that we should not be updating depths on a per-IO
basis.  He's right. In fact, BFQ oddly enough does it from the
->limit_depth hook, but the shallow depth counts remain static.

This series cleans that up the ->limit_depth() handling, and keeps it
out of the hot path.

Mike, this should (still) fix your hangs with BFQ. This series is
(functionally) identical to the bundled up version I sent you earlier.

 block/bfq-iosched.c     |  113 +++++++++++++++++++++++++-----------------------
 block/bfq-iosched.h     |    6 --
 block/blk-mq.c          |    6 +-
 block/kyber-iosched.c   |    3 +
 include/linux/sbitmap.h |   11 ++++
 lib/sbitmap.c           |   19 +++++++-
 6 files changed, 95 insertions(+), 63 deletions(-)

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/7] blk-mq: don't call into depth limiting for reserved tags
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-09 20:49 ` [PATCH 2/7] bfq-iosched: don't worry about reserved tags in limit_depth Jens Axboe
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

It's not useful, they are internal and/or error handling recovery
commands.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4e9d83594cca..64630caaf27e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -360,9 +360,11 @@ static struct request *blk_mq_get_request(struct request_queue *q,
 
 		/*
 		 * Flush requests are special and go directly to the
-		 * dispatch list.
+		 * dispatch list. Don't include reserved tags in the
+		 * limiting, as it isn't useful.
 		 */
-		if (!op_is_flush(op) && e->type->ops.mq.limit_depth)
+		if (!op_is_flush(op) && e->type->ops.mq.limit_depth &&
+		    !(data->flags & BLK_MQ_REQ_RESERVED))
 			e->type->ops.mq.limit_depth(op, data);
 	}
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/7] bfq-iosched: don't worry about reserved tags in limit_depth
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
  2018-05-09 20:49 ` [PATCH 1/7] blk-mq: don't call into depth limiting for reserved tags Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-09 20:49 ` [PATCH 3/7] bfq: calculate shallow depths at init time Jens Axboe
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

Reserved tags are used for error handling, we don't need to
care about them for regular IO. The core won't call us for these
anyway.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/bfq-iosched.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index ebc264c87a09..246ae25a5f34 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -542,14 +542,7 @@ static void bfq_limit_depth(unsigned int op, struct blk_mq_alloc_data *data)
 	if (op_is_sync(op) && !op_is_write(op))
 		return;
 
-	if (data->flags & BLK_MQ_REQ_RESERVED) {
-		if (unlikely(!tags->nr_reserved_tags)) {
-			WARN_ON_ONCE(1);
-			return;
-		}
-		bt = &tags->breserved_tags;
-	} else
-		bt = &tags->bitmap_tags;
+	bt = &tags->bitmap_tags;
 
 	if (unlikely(bfqd->sb_shift != bt->sb.shift))
 		bfq_update_depths(bfqd, bt);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/7] bfq: calculate shallow depths at init time
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
  2018-05-09 20:49 ` [PATCH 1/7] blk-mq: don't call into depth limiting for reserved tags Jens Axboe
  2018-05-09 20:49 ` [PATCH 2/7] bfq-iosched: don't worry about reserved tags in limit_depth Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-09 20:49 ` [PATCH 4/7] sbitmap: add helper to inform the core about shallow depth limiting Jens Axboe
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

It doesn't change, so don't put it in the per-IO hot path.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/bfq-iosched.c | 97 +++++++++++++++++++++++++++--------------------------
 1 file changed, 50 insertions(+), 47 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 246ae25a5f34..b7722668e295 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -487,46 +487,6 @@ static struct request *bfq_choose_req(struct bfq_data *bfqd,
 }
 
 /*
- * See the comments on bfq_limit_depth for the purpose of
- * the depths set in the function.
- */
-static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
-{
-	bfqd->sb_shift = bt->sb.shift;
-
-	/*
-	 * In-word depths if no bfq_queue is being weight-raised:
-	 * leaving 25% of tags only for sync reads.
-	 *
-	 * In next formulas, right-shift the value
-	 * (1U<<bfqd->sb_shift), instead of computing directly
-	 * (1U<<(bfqd->sb_shift - something)), to be robust against
-	 * any possible value of bfqd->sb_shift, without having to
-	 * limit 'something'.
-	 */
-	/* no more than 50% of tags for async I/O */
-	bfqd->word_depths[0][0] = max((1U<<bfqd->sb_shift)>>1, 1U);
-	/*
-	 * no more than 75% of tags for sync writes (25% extra tags
-	 * w.r.t. async I/O, to prevent async I/O from starving sync
-	 * writes)
-	 */
-	bfqd->word_depths[0][1] = max(((1U<<bfqd->sb_shift) * 3)>>2, 1U);
-
-	/*
-	 * In-word depths in case some bfq_queue is being weight-
-	 * raised: leaving ~63% of tags for sync reads. This is the
-	 * highest percentage for which, in our tests, application
-	 * start-up times didn't suffer from any regression due to tag
-	 * shortage.
-	 */
-	/* no more than ~18% of tags for async I/O */
-	bfqd->word_depths[1][0] = max(((1U<<bfqd->sb_shift) * 3)>>4, 1U);
-	/* no more than ~37% of tags for sync writes (~20% extra tags) */
-	bfqd->word_depths[1][1] = max(((1U<<bfqd->sb_shift) * 6)>>4, 1U);
-}
-
-/*
  * Async I/O can easily starve sync I/O (both sync reads and sync
  * writes), by consuming all tags. Similarly, storms of sync writes,
  * such as those that sync(2) may trigger, can starve sync reads.
@@ -535,18 +495,11 @@ static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
  */
 static void bfq_limit_depth(unsigned int op, struct blk_mq_alloc_data *data)
 {
-	struct blk_mq_tags *tags = blk_mq_tags_from_data(data);
 	struct bfq_data *bfqd = data->q->elevator->elevator_data;
-	struct sbitmap_queue *bt;
 
 	if (op_is_sync(op) && !op_is_write(op))
 		return;
 
-	bt = &tags->bitmap_tags;
-
-	if (unlikely(bfqd->sb_shift != bt->sb.shift))
-		bfq_update_depths(bfqd, bt);
-
 	data->shallow_depth =
 		bfqd->word_depths[!!bfqd->wr_busy_queues][op_is_sync(op)];
 
@@ -5098,6 +5051,55 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)
 	__bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq);
 }
 
+/*
+ * See the comments on bfq_limit_depth for the purpose of
+ * the depths set in the function.
+ */
+static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
+{
+	bfqd->sb_shift = bt->sb.shift;
+
+	/*
+	 * In-word depths if no bfq_queue is being weight-raised:
+	 * leaving 25% of tags only for sync reads.
+	 *
+	 * In next formulas, right-shift the value
+	 * (1U<<bfqd->sb_shift), instead of computing directly
+	 * (1U<<(bfqd->sb_shift - something)), to be robust against
+	 * any possible value of bfqd->sb_shift, without having to
+	 * limit 'something'.
+	 */
+	/* no more than 50% of tags for async I/O */
+	bfqd->word_depths[0][0] = max((1U<<bfqd->sb_shift)>>1, 1U);
+	/*
+	 * no more than 75% of tags for sync writes (25% extra tags
+	 * w.r.t. async I/O, to prevent async I/O from starving sync
+	 * writes)
+	 */
+	bfqd->word_depths[0][1] = max(((1U<<bfqd->sb_shift) * 3)>>2, 1U);
+
+	/*
+	 * In-word depths in case some bfq_queue is being weight-
+	 * raised: leaving ~63% of tags for sync reads. This is the
+	 * highest percentage for which, in our tests, application
+	 * start-up times didn't suffer from any regression due to tag
+	 * shortage.
+	 */
+	/* no more than ~18% of tags for async I/O */
+	bfqd->word_depths[1][0] = max(((1U<<bfqd->sb_shift) * 3)>>4, 1U);
+	/* no more than ~37% of tags for sync writes (~20% extra tags) */
+	bfqd->word_depths[1][1] = max(((1U<<bfqd->sb_shift) * 6)>>4, 1U);
+}
+
+static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index)
+{
+	struct bfq_data *bfqd = hctx->queue->elevator->elevator_data;
+	struct blk_mq_tags *tags = hctx->sched_tags;
+
+	bfq_update_depths(bfqd, &tags->bitmap_tags);
+	return 0;
+}
+
 static void bfq_exit_queue(struct elevator_queue *e)
 {
 	struct bfq_data *bfqd = e->elevator_data;
@@ -5519,6 +5521,7 @@ static struct elevator_type iosched_bfq_mq = {
 		.requests_merged	= bfq_requests_merged,
 		.request_merged		= bfq_request_merged,
 		.has_work		= bfq_has_work,
+		.init_hctx		= bfq_init_hctx,
 		.init_sched		= bfq_init_queue,
 		.exit_sched		= bfq_exit_queue,
 	},
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/7] sbitmap: add helper to inform the core about shallow depth limiting
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
                   ` (2 preceding siblings ...)
  2018-05-09 20:49 ` [PATCH 3/7] bfq: calculate shallow depths at init time Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-09 20:49 ` [PATCH 5/7] bfq-iosched: update shallow depth to smallest one used Jens Axboe
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

If a user of sbitmap limits the shallow depth on his own, then
we need to inform the lower layers. Otherwise we can run into
a situation where the user has limited the depth to something
smaller than our wake batch count, which can cause hangs.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/sbitmap.h | 11 +++++++++++
 lib/sbitmap.c           | 19 ++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
index 841585f6e5f2..99059789f45f 100644
--- a/include/linux/sbitmap.h
+++ b/include/linux/sbitmap.h
@@ -164,6 +164,17 @@ static inline void sbitmap_free(struct sbitmap *sb)
 void sbitmap_resize(struct sbitmap *sb, unsigned int depth);
 
 /**
+ * sbitmap_queue_shallow_depth() - Inform sbitmap about shallow depth changes
+ * @sbq: Bitmap queue in question
+ * @depth: Shallow depth limit
+ *
+ * Due to how sbitmap does batched wakes, if a user of sbitmap updates the
+ * shallow depth, then we might need to update our batched wake counts.
+ *
+ */
+void sbitmap_queue_shallow_depth(struct sbitmap_queue *sbq, unsigned int depth);
+
+/**
  * sbitmap_get() - Try to allocate a free bit from a &struct sbitmap.
  * @sb: Bitmap to allocate from.
  * @alloc_hint: Hint for where to start searching for a free bit.
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index e6a9c06ec70c..a4fb48e4c26b 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -327,7 +327,8 @@ int sbitmap_queue_init_node(struct sbitmap_queue *sbq, unsigned int depth,
 }
 EXPORT_SYMBOL_GPL(sbitmap_queue_init_node);
 
-void sbitmap_queue_resize(struct sbitmap_queue *sbq, unsigned int depth)
+static void sbitmap_queue_update_batch_wake(struct sbitmap_queue *sbq,
+					    unsigned int depth)
 {
 	unsigned int wake_batch = sbq_calc_wake_batch(depth);
 	int i;
@@ -342,6 +343,11 @@ void sbitmap_queue_resize(struct sbitmap_queue *sbq, unsigned int depth)
 		for (i = 0; i < SBQ_WAIT_QUEUES; i++)
 			atomic_set(&sbq->ws[i].wait_cnt, 1);
 	}
+}
+
+void sbitmap_queue_resize(struct sbitmap_queue *sbq, unsigned int depth)
+{
+	sbitmap_queue_update_batch_wake(sbq, depth);
 	sbitmap_resize(&sbq->sb, depth);
 }
 EXPORT_SYMBOL_GPL(sbitmap_queue_resize);
@@ -403,6 +409,17 @@ int __sbitmap_queue_get_shallow(struct sbitmap_queue *sbq,
 }
 EXPORT_SYMBOL_GPL(__sbitmap_queue_get_shallow);
 
+/*
+ * User has limited the shallow depth to 'depth', update batch wake counts
+ * if depth is smaller than the sbitmap_queue depth
+ */
+void sbitmap_queue_shallow_depth(struct sbitmap_queue *sbq, unsigned int depth)
+{
+	if (depth < sbq->sb.depth)
+		sbitmap_queue_update_batch_wake(sbq, depth);
+}
+EXPORT_SYMBOL_GPL(sbitmap_queue_shallow_depth);
+
 static struct sbq_wait_state *sbq_wake_ptr(struct sbitmap_queue *sbq)
 {
 	int i, wake_index;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/7] bfq-iosched: update shallow depth to smallest one used
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
                   ` (3 preceding siblings ...)
  2018-05-09 20:49 ` [PATCH 4/7] sbitmap: add helper to inform the core about shallow depth limiting Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-09 20:49 ` [PATCH 6/7] bfq-iosched: remove unused variable Jens Axboe
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

If our shallow depth is smaller than the wake batching of sbitmap,
we can introduce hangs. Ensure that sbitmap knows how low we'll go.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/bfq-iosched.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index b7722668e295..cba6e82153a2 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -5053,10 +5053,13 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)
 
 /*
  * See the comments on bfq_limit_depth for the purpose of
- * the depths set in the function.
+ * the depths set in the function. Return minimum shallow depth we'll use.
  */
-static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
+static unsigned int bfq_update_depths(struct bfq_data *bfqd,
+				      struct sbitmap_queue *bt)
 {
+	unsigned int i, j, min_shallow = UINT_MAX;
+
 	bfqd->sb_shift = bt->sb.shift;
 
 	/*
@@ -5089,14 +5092,22 @@ static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
 	bfqd->word_depths[1][0] = max(((1U<<bfqd->sb_shift) * 3)>>4, 1U);
 	/* no more than ~37% of tags for sync writes (~20% extra tags) */
 	bfqd->word_depths[1][1] = max(((1U<<bfqd->sb_shift) * 6)>>4, 1U);
+
+	for (i = 0; i < 2; i++)
+		for (j = 0; j < 2; j++)
+			min_shallow = min(min_shallow, bfqd->word_depths[i][j]);
+
+	return min_shallow;
 }
 
 static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index)
 {
 	struct bfq_data *bfqd = hctx->queue->elevator->elevator_data;
 	struct blk_mq_tags *tags = hctx->sched_tags;
+	unsigned int min_shallow;
 
-	bfq_update_depths(bfqd, &tags->bitmap_tags);
+	min_shallow = bfq_update_depths(bfqd, &tags->bitmap_tags);
+	sbitmap_queue_shallow_depth(&tags->bitmap_tags, min_shallow);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/7] bfq-iosched: remove unused variable
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
                   ` (4 preceding siblings ...)
  2018-05-09 20:49 ` [PATCH 5/7] bfq-iosched: update shallow depth to smallest one used Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-09 20:49 ` [PATCH 7/7] kyber-iosched: update shallow depth when setting up hardware queue Jens Axboe
  2018-05-10  4:32 ` [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Paolo Valente
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

bfqd->sb_shift was attempted used as a cache for the sbitmap queue
shift, but we don't need it, as it never changes. Kill it with fire.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/bfq-iosched.c | 16 +++++++---------
 block/bfq-iosched.h |  6 ------
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index cba6e82153a2..07b43ea124b0 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -5060,26 +5060,24 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
 {
 	unsigned int i, j, min_shallow = UINT_MAX;
 
-	bfqd->sb_shift = bt->sb.shift;
-
 	/*
 	 * In-word depths if no bfq_queue is being weight-raised:
 	 * leaving 25% of tags only for sync reads.
 	 *
 	 * In next formulas, right-shift the value
-	 * (1U<<bfqd->sb_shift), instead of computing directly
-	 * (1U<<(bfqd->sb_shift - something)), to be robust against
-	 * any possible value of bfqd->sb_shift, without having to
+	 * (1U<<bt->sb.shift), instead of computing directly
+	 * (1U<<(bt->sb.shift - something)), to be robust against
+	 * any possible value of bt->sb.shift, without having to
 	 * limit 'something'.
 	 */
 	/* no more than 50% of tags for async I/O */
-	bfqd->word_depths[0][0] = max((1U<<bfqd->sb_shift)>>1, 1U);
+	bfqd->word_depths[0][0] = max((1U << bt->sb.shift) >> 1, 1U);
 	/*
 	 * no more than 75% of tags for sync writes (25% extra tags
 	 * w.r.t. async I/O, to prevent async I/O from starving sync
 	 * writes)
 	 */
-	bfqd->word_depths[0][1] = max(((1U<<bfqd->sb_shift) * 3)>>2, 1U);
+	bfqd->word_depths[0][1] = max(((1U << bt->sb.shift) * 3) >> 2, 1U);
 
 	/*
 	 * In-word depths in case some bfq_queue is being weight-
@@ -5089,9 +5087,9 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
 	 * shortage.
 	 */
 	/* no more than ~18% of tags for async I/O */
-	bfqd->word_depths[1][0] = max(((1U<<bfqd->sb_shift) * 3)>>4, 1U);
+	bfqd->word_depths[1][0] = max(((1U << bt->sb.shift) * 3) >> 4, 1U);
 	/* no more than ~37% of tags for sync writes (~20% extra tags) */
-	bfqd->word_depths[1][1] = max(((1U<<bfqd->sb_shift) * 6)>>4, 1U);
+	bfqd->word_depths[1][1] = max(((1U << bt->sb.shift) * 6) >> 4, 1U);
 
 	for (i = 0; i < 2; i++)
 		for (j = 0; j < 2; j++)
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 8ec7ff92cd6f..faac509cb35e 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -636,12 +636,6 @@ struct bfq_data {
 	struct bfq_queue *bio_bfqq;
 
 	/*
-	 * Cached sbitmap shift, used to compute depth limits in
-	 * bfq_update_depths.
-	 */
-	unsigned int sb_shift;
-
-	/*
 	 * Depth limits used in bfq_limit_depth (see comments on the
 	 * function)
 	 */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/7] kyber-iosched: update shallow depth when setting up hardware queue
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
                   ` (5 preceding siblings ...)
  2018-05-09 20:49 ` [PATCH 6/7] bfq-iosched: remove unused variable Jens Axboe
@ 2018-05-09 20:49 ` Jens Axboe
  2018-05-10  4:32 ` [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Paolo Valente
  7 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-09 20:49 UTC (permalink / raw)
  To: linux-block; +Cc: osandov, efault, paolo.valente, Jens Axboe

We don't expect the async depth to be smaller than the wake batch
count for sbitmap, but just in case, inform sbitmap of what shallow
depth kyber may use.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/kyber-iosched.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/kyber-iosched.c b/block/kyber-iosched.c
index 564967fafe5f..b1b927224cd4 100644
--- a/block/kyber-iosched.c
+++ b/block/kyber-iosched.c
@@ -378,6 +378,7 @@ static void kyber_exit_sched(struct elevator_queue *e)
 
 static int kyber_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx)
 {
+	struct kyber_queue_data *kqd = hctx->queue->elevator->elevator_data;
 	struct kyber_hctx_data *khd;
 	int i;
 
@@ -400,6 +401,8 @@ static int kyber_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx)
 	khd->batching = 0;
 
 	hctx->sched_data = khd;
+	sbitmap_queue_shallow_depth(&hctx->sched_tags->bitmap_tags,
+					kqd->async_depth);
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth
  2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
                   ` (6 preceding siblings ...)
  2018-05-09 20:49 ` [PATCH 7/7] kyber-iosched: update shallow depth when setting up hardware queue Jens Axboe
@ 2018-05-10  4:32 ` Paolo Valente
  2018-05-10 16:20   ` Jens Axboe
  7 siblings, 1 reply; 10+ messages in thread
From: Paolo Valente @ 2018-05-10  4:32 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Omar Sandoval, Mike Galbraith, Ulf Hansson,
	Linus Walleij, Mark Brown



> Il giorno 09 mag 2018, alle ore 22:49, Jens Axboe <axboe@kernel.dk> ha =
scritto:
>=20
> Omar had some valid complaints about the previous patchset, mostly
> around the fact that we should not be updating depths on a per-IO
> basis.  He's right. In fact, BFQ oddly enough does it from the
> ->limit_depth hook, but the shallow depth counts remain static.
>=20
> This series cleans that up the ->limit_depth() handling, and keeps it
> out of the hot path.
>=20
> Mike, this should (still) fix your hangs with BFQ. This series is
> (functionally) identical to the bundled up version I sent you earlier.
>=20

Only one question/curiosity: is performance unaffected by the lowering =
of
the wake batch counts?

Apart from that,
Acked-by: Paolo Valente <paolo.valente@linaro.org>

Thanks,
Paolo

> block/bfq-iosched.c     |  113 =
+++++++++++++++++++++++++-----------------------
> block/bfq-iosched.h     |    6 --
> block/blk-mq.c          |    6 +-
> block/kyber-iosched.c   |    3 +
> include/linux/sbitmap.h |   11 ++++
> lib/sbitmap.c           |   19 +++++++-
> 6 files changed, 95 insertions(+), 63 deletions(-)
>=20
> --=20
> Jens Axboe
>=20

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth
  2018-05-10  4:32 ` [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Paolo Valente
@ 2018-05-10 16:20   ` Jens Axboe
  0 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2018-05-10 16:20 UTC (permalink / raw)
  To: Paolo Valente
  Cc: linux-block, Omar Sandoval, Mike Galbraith, Ulf Hansson,
	Linus Walleij, Mark Brown

On 5/9/18 10:32 PM, Paolo Valente wrote:
> 
> 
>> Il giorno 09 mag 2018, alle ore 22:49, Jens Axboe <axboe@kernel.dk> ha scritto:
>>
>> Omar had some valid complaints about the previous patchset, mostly
>> around the fact that we should not be updating depths on a per-IO
>> basis.  He's right. In fact, BFQ oddly enough does it from the
>> ->limit_depth hook, but the shallow depth counts remain static.
>>
>> This series cleans that up the ->limit_depth() handling, and keeps it
>> out of the hot path.
>>
>> Mike, this should (still) fix your hangs with BFQ. This series is
>> (functionally) identical to the bundled up version I sent you earlier.
>>
> 
> Only one question/curiosity: is performance unaffected by the lowering of
> the wake batch counts?

It's hard to discuss performance within the realm of "it hangs without
it", there's just no way around this. That said, We still have the
rolling waitqueues (default is 8) which also helps in reducing the
overhead on both wakeups and adding to wait queues. So we should still
be quite fine.

As it so happens, there's another bug in wake batch accounting in
sbitmap, which would have defeated much of the win over time anyway. New
series coming with that extra patch.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-05-10 16:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 20:49 [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Jens Axboe
2018-05-09 20:49 ` [PATCH 1/7] blk-mq: don't call into depth limiting for reserved tags Jens Axboe
2018-05-09 20:49 ` [PATCH 2/7] bfq-iosched: don't worry about reserved tags in limit_depth Jens Axboe
2018-05-09 20:49 ` [PATCH 3/7] bfq: calculate shallow depths at init time Jens Axboe
2018-05-09 20:49 ` [PATCH 4/7] sbitmap: add helper to inform the core about shallow depth limiting Jens Axboe
2018-05-09 20:49 ` [PATCH 5/7] bfq-iosched: update shallow depth to smallest one used Jens Axboe
2018-05-09 20:49 ` [PATCH 6/7] bfq-iosched: remove unused variable Jens Axboe
2018-05-09 20:49 ` [PATCH 7/7] kyber-iosched: update shallow depth when setting up hardware queue Jens Axboe
2018-05-10  4:32 ` [PATCHSET v2 0/7] blk-mq-sched and sbitmap shallow depth Paolo Valente
2018-05-10 16:20   ` Jens Axboe

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.