linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai3@huawei.com>
To: <axboe@kernel.dk>, <yukuai3@huawei.com>,
	<andriy.shevchenko@linux.intel.com>, <john.garry@huawei.com>,
	<ming.lei@redhat.com>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<yi.zhang@huawei.com>
Subject: [PATCH -next RFC v2 6/8] blk-mq: force tag preemption for split bios
Date: Fri, 8 Apr 2022 15:39:14 +0800	[thread overview]
Message-ID: <20220408073916.1428590-7-yukuai3@huawei.com> (raw)
In-Reply-To: <20220408073916.1428590-1-yukuai3@huawei.com>

For HDD, sequential io is much faster than random io, thus it's better
to issue split io continuously. However, this is broken when tag preemption
is disabled, because wakers can only get one tag each time.

Thus tag preemption should be disabled for split bios, specifically the
first bio won't preempt tag, and following split bios will preempt tag.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-merge.c         | 9 ++++++++-
 block/blk-mq.c            | 1 +
 include/linux/blk_types.h | 4 ++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 7771dacc99cb..cab6ca681513 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -343,12 +343,19 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,
 
 	if (split) {
 		/* there isn't chance to merge the splitted bio */
-		split->bi_opf |= REQ_NOMERGE;
+		split->bi_opf |= (REQ_NOMERGE | REQ_SPLIT);
+		if ((*bio)->bi_opf & REQ_SPLIT)
+			split->bi_opf |= REQ_PREEMPT;
+		else
+			(*bio)->bi_opf |= REQ_SPLIT;
 
 		bio_chain(split, *bio);
 		trace_block_split(split, (*bio)->bi_iter.bi_sector);
 		submit_bio_noacct(*bio);
 		*bio = split;
+	} else {
+		if ((*bio)->bi_opf & REQ_SPLIT)
+			(*bio)->bi_opf |= REQ_PREEMPT;
 	}
 }
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ed3ed86f7dd2..909420c5186c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2737,6 +2737,7 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
 		.q		= q,
 		.nr_tags	= 1,
 		.cmd_flags	= bio->bi_opf,
+		.preemption	= (bio->bi_opf & REQ_PREEMPT),
 	};
 	struct request *rq;
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index c62274466e72..6b56e271f926 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -418,6 +418,8 @@ enum req_flag_bits {
 	/* for driver use */
 	__REQ_DRV,
 	__REQ_SWAP,		/* swapping request. */
+	__REQ_SPLIT,
+	__REQ_PREEMPT,
 	__REQ_NR_BITS,		/* stops here */
 };
 
@@ -443,6 +445,8 @@ enum req_flag_bits {
 
 #define REQ_DRV			(1ULL << __REQ_DRV)
 #define REQ_SWAP		(1ULL << __REQ_SWAP)
+#define REQ_SPLIT		(1ULL << __REQ_SPLIT)
+#define REQ_PREEMPT		(1ULL << __REQ_PREEMPT)
 
 #define REQ_FAILFAST_MASK \
 	(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
-- 
2.31.1


  parent reply	other threads:[~2022-04-08  7:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08  7:39 [PATCH -next RFC v2 0/8] improve tag allocation under heavy load Yu Kuai
2022-04-08  7:39 ` [PATCH -next RFC v2 1/8] sbitmap: record the number of waiters for each waitqueue Yu Kuai
2022-04-08  7:39 ` [PATCH -next RFC v2 2/8] blk-mq: call 'bt_wait_ptr()' later in blk_mq_get_tag() Yu Kuai
2022-04-08 14:20   ` Bart Van Assche
2022-04-09  2:09     ` yukuai (C)
2022-04-08  7:39 ` [PATCH -next RFC v2 3/8] sbitmap: make sure waitqueues are balanced Yu Kuai
2022-04-15  6:31   ` Li, Ming
2022-04-15  7:07     ` yukuai (C)
2022-04-08  7:39 ` [PATCH -next RFC v2 4/8] blk-mq: don't preempt tag under heavy load Yu Kuai
2022-04-08 14:24   ` Bart Van Assche
2022-04-09  2:38     ` yukuai (C)
2022-04-08  7:39 ` [PATCH -next RFC v2 5/8] sbitmap: force tag preemption if free tags are sufficient Yu Kuai
2022-04-08  7:39 ` Yu Kuai [this message]
2022-04-08  7:39 ` [PATCH -next RFC v2 7/8] blk-mq: record how many tags are needed for splited bio Yu Kuai
2022-04-08  7:39 ` [PATCH -next RFC v2 8/8] sbitmap: wake up the number of threads based on required tags Yu Kuai
2022-04-08 14:31   ` Bart Van Assche
2022-04-09  2:19     ` yukuai (C)
2022-04-08 21:13   ` Bart Van Assche
2022-04-09  2:17     ` yukuai (C)
2022-04-09  4:16       ` Bart Van Assche
2022-04-09  7:01         ` yukuai (C)
2022-04-12  3:20           ` Bart Van Assche
2022-04-08 19:10 ` [PATCH -next RFC v2 0/8] improve tag allocation under heavy load Jens Axboe
2022-04-09  2:26   ` yukuai (C)
2022-04-09  2:28     ` Jens Axboe
2022-04-09  2:34       ` yukuai (C)
2022-04-09  7:14       ` yukuai (C)
2022-04-09 21:31       ` 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=20220408073916.1428590-7-yukuai3@huawei.com \
    --to=yukuai3@huawei.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=axboe@kernel.dk \
    --cc=john.garry@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=yi.zhang@huawei.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).