All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 0/2] Fix raid rebuild performance regression
@ 2022-03-11 17:30 Jens Axboe
  2022-03-11 17:30 ` [PATCH 1/2] block: ensure plug merging checks the correct queue at least once Jens Axboe
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jens Axboe @ 2022-03-11 17:30 UTC (permalink / raw)
  To: linux-block; +Cc: song, linux-raid, llowrey, i400sjon, rogerheflin

Hi,

This should fix the reported RAID rebuild regression, while also
providing better performance for other workloads particularly on
rotating storage.

-- 
Jens Axboe



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

* [PATCH 1/2] block: ensure plug merging checks the correct queue at least once
  2022-03-11 17:30 [PATCHSET 0/2] Fix raid rebuild performance regression Jens Axboe
@ 2022-03-11 17:30 ` Jens Axboe
  2022-03-11 17:30 ` [PATCH 2/2] block: flush plug based on hardware and software queue order Jens Axboe
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-03-11 17:30 UTC (permalink / raw)
  To: linux-block; +Cc: song, linux-raid, llowrey, i400sjon, rogerheflin, Jens Axboe

Song reports that a RAID rebuild workload runs much slower recently,
and it is seeing a lot less merging than it did previously. The reason
is that a previous commit reduced the amount of work we do for plug
merging. RAID rebuild interleaves requests between disks, so a last-entry
check in plug merging always misses a merge opportunity since we always
find a different disk than what we are looking for.

Modify the logic such that it's still a one-hit cache, but ensure that
we check enough to find the right target before giving up.

Fixes: d38a9c04c0d5 ("block: only check previous entry for plug merge attempt")
Reported-by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-merge.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index f5255991b773..8d8177f71ebd 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -1087,12 +1087,20 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
 	if (!plug || rq_list_empty(plug->mq_list))
 		return false;
 
-	/* check the previously added entry for a quick merge attempt */
-	rq = rq_list_peek(&plug->mq_list);
-	if (rq->q == q) {
-		if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
-				BIO_MERGE_OK)
-			return true;
+	rq_list_for_each(&plug->mq_list, rq) {
+		if (rq->q == q) {
+			if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
+			    BIO_MERGE_OK)
+				return true;
+			break;
+		}
+
+		/*
+		 * Only keep iterating plug list for merges if we have multiple
+		 * queues
+		 */
+		if (!plug->multiple_queues)
+			break;
 	}
 	return false;
 }
-- 
2.35.1


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

* [PATCH 2/2] block: flush plug based on hardware and software queue order
  2022-03-11 17:30 [PATCHSET 0/2] Fix raid rebuild performance regression Jens Axboe
  2022-03-11 17:30 ` [PATCH 1/2] block: ensure plug merging checks the correct queue at least once Jens Axboe
@ 2022-03-11 17:30 ` Jens Axboe
  2022-03-11 18:00 ` [PATCHSET 0/2] Fix raid rebuild performance regression Song Liu
  2022-03-12  6:54 ` Thorsten Leemhuis
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-03-11 17:30 UTC (permalink / raw)
  To: linux-block; +Cc: song, linux-raid, llowrey, i400sjon, rogerheflin, Jens Axboe

We used to sort the plug list if we had multiple queues before dispatching
requests to the IO scheduler. This usually isn't needed, but for certain
workloads that interleave requests to disks, it's a less efficient to
process the plug list one-by-one if everything is interleaved.

Don't sort the list, but skip through it and flush out entries that have
the same target at the same time.

Fixes: df87eb0fce8f ("block: get rid of plug list sorting")
Reported-by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 59 ++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 31 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 862d91c6112e..213bb5979bed 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2573,13 +2573,36 @@ static void __blk_mq_flush_plug_list(struct request_queue *q,
 	q->mq_ops->queue_rqs(&plug->mq_list);
 }
 
+static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
+{
+	struct blk_mq_hw_ctx *this_hctx = NULL;
+	struct blk_mq_ctx *this_ctx = NULL;
+	struct request *requeue_list = NULL;
+	unsigned int depth = 0;
+	LIST_HEAD(list);
+
+	do {
+		struct request *rq = rq_list_pop(&plug->mq_list);
+
+		if (!this_hctx) {
+			this_hctx = rq->mq_hctx;
+			this_ctx = rq->mq_ctx;
+		} else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx) {
+			rq_list_add(&requeue_list, rq);
+			continue;
+		}
+		list_add_tail(&rq->queuelist, &list);
+		depth++;
+	} while (!rq_list_empty(plug->mq_list));
+
+	plug->mq_list = requeue_list;
+	trace_block_unplug(this_hctx->queue, depth, !from_sched);
+	blk_mq_sched_insert_requests(this_hctx, this_ctx, &list, from_sched);
+}
+
 void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 {
-	struct blk_mq_hw_ctx *this_hctx;
-	struct blk_mq_ctx *this_ctx;
 	struct request *rq;
-	unsigned int depth;
-	LIST_HEAD(list);
 
 	if (rq_list_empty(plug->mq_list))
 		return;
@@ -2615,35 +2638,9 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 			return;
 	}
 
-	this_hctx = NULL;
-	this_ctx = NULL;
-	depth = 0;
 	do {
-		rq = rq_list_pop(&plug->mq_list);
-
-		if (!this_hctx) {
-			this_hctx = rq->mq_hctx;
-			this_ctx = rq->mq_ctx;
-		} else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx) {
-			trace_block_unplug(this_hctx->queue, depth,
-						!from_schedule);
-			blk_mq_sched_insert_requests(this_hctx, this_ctx,
-						&list, from_schedule);
-			depth = 0;
-			this_hctx = rq->mq_hctx;
-			this_ctx = rq->mq_ctx;
-
-		}
-
-		list_add(&rq->queuelist, &list);
-		depth++;
+		blk_mq_dispatch_plug_list(plug, from_schedule);
 	} while (!rq_list_empty(plug->mq_list));
-
-	if (!list_empty(&list)) {
-		trace_block_unplug(this_hctx->queue, depth, !from_schedule);
-		blk_mq_sched_insert_requests(this_hctx, this_ctx, &list,
-						from_schedule);
-	}
 }
 
 void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
-- 
2.35.1


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

* Re: [PATCHSET 0/2] Fix raid rebuild performance regression
  2022-03-11 17:30 [PATCHSET 0/2] Fix raid rebuild performance regression Jens Axboe
  2022-03-11 17:30 ` [PATCH 1/2] block: ensure plug merging checks the correct queue at least once Jens Axboe
  2022-03-11 17:30 ` [PATCH 2/2] block: flush plug based on hardware and software queue order Jens Axboe
@ 2022-03-11 18:00 ` Song Liu
  2022-03-12  6:54 ` Thorsten Leemhuis
  3 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2022-03-11 18:00 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, linux-raid, Larkin Lowrey, Wilson Jonathan, Roger Heflin

On Fri, Mar 11, 2022 at 9:30 AM Jens Axboe <axboe@kernel.dk> wrote:
>
> Hi,
>
> This should fix the reported RAID rebuild regression, while also
> providing better performance for other workloads particularly on
> rotating storage.

Thanks for the fix!

Reviewed-by: Song Liu <songliubraving@fb.com>

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

* Re: [PATCHSET 0/2] Fix raid rebuild performance regression
  2022-03-11 17:30 [PATCHSET 0/2] Fix raid rebuild performance regression Jens Axboe
                   ` (2 preceding siblings ...)
  2022-03-11 18:00 ` [PATCHSET 0/2] Fix raid rebuild performance regression Song Liu
@ 2022-03-12  6:54 ` Thorsten Leemhuis
  3 siblings, 0 replies; 5+ messages in thread
From: Thorsten Leemhuis @ 2022-03-12  6:54 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: song, linux-raid, llowrey, i400sjon, rogerheflin

Hi, this is your Linux kernel regression tracker.

On 11.03.22 18:30, Jens Axboe wrote:
>
> This should fix the reported RAID rebuild regression, while also
> providing better performance for other workloads particularly on
> rotating storage.

Nitpicking: From the list of CCed people it seems these patches are
fixing this regression:

https://lore.kernel.org/linux-raid/0eb91a43-a153-6e29-14b6-65f97b9f3d99@nuclearwinter.com/

Then the patch descriptions for the two commits should include a link
tag to the report, as per using lore.kernel.org/r/, as explained in
'Documentation/process/submitting-patches.rst' and
'Documentation/process/5.Posting.rst'. And the original reporters likely
should be honored with a "Reported-by", too. The former would my
regression tracking life a lot easier, as regzbot relies on those links
that are useful for other purposes, too (as explained in the docs).

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)

P.S.: As the Linux kernel's regression tracker I'm getting a lot of
reports on my table. I can only look briefly into most of them and lack
knowledge about most of the areas they concern. I thus unfortunately
will sometimes get things wrong or miss something important. I hope
that's not the case here; if you think it is, don't hesitate to tell me
in a public reply, it's in everyone's interest to set the public record
straight.

#regzbot ^backmonitor:
https://lore.kernel.org/linux-raid/0eb91a43-a153-6e29-14b6-65f97b9f3d99@nuclearwinter.com/

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

end of thread, other threads:[~2022-03-12  6:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 17:30 [PATCHSET 0/2] Fix raid rebuild performance regression Jens Axboe
2022-03-11 17:30 ` [PATCH 1/2] block: ensure plug merging checks the correct queue at least once Jens Axboe
2022-03-11 17:30 ` [PATCH 2/2] block: flush plug based on hardware and software queue order Jens Axboe
2022-03-11 18:00 ` [PATCHSET 0/2] Fix raid rebuild performance regression Song Liu
2022-03-12  6:54 ` Thorsten Leemhuis

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.