Skip to contentSkip to conversation

blk-mq: fix fix blk_mq_tagset_busy_iter

PATCH In review Ming Lei 4 participants 7 messages Aug 2, 2018

Subsystems (2)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

v2 cover blk-mq: fix fix blk_mq_tagset_busy_iter

Hi Jens,

The two patches fixes boot hang issue in lots of test vm system. And the cause is in blk_mq_tagset_busy_iter().

V2:
- move blk_mq_request_started() into header file as suggested by James

Ming Lei (2):
blk-mq: move blk_mq_request_started() into header file
blk-mq: fix blk_mq_tagset_busy_iter

 block/blk-mq-tag.c     |  2 +-
 block/blk-mq.c         |  6 ------
 block/blk-mq.h         |  9 ---------
 include/linux/blk-mq.h | 15 ++++++++++++++-
 4 files changed, 15 insertions(+), 17 deletions(-)
Cc Josef Bacik <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Mark Brown <[email protected]>
Cc Matt Hart <[email protected]>
Cc Johannes Thumshirn <[email protected]>
Cc John Garry <[email protected]>
Cc Hannes Reinecke <[email protected]>,
Cc "Martin K. Petersen" <[email protected]>,
Cc James Bottomley <[email protected]>
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH v2 1/2 blk-mq: move blk_mq_request_started() into header file

Define it as static inline given it might be called in fast path.

Cc Josef Bacik <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Mark Brown <[email protected]>
Cc Matt Hart <[email protected]>
Cc Johannes Thumshirn <[email protected]>
Cc John Garry <[email protected]>
Cc Hannes Reinecke <[email protected]>,
Cc "Martin K. Petersen" <[email protected]>,
Cc James Bottomley <[email protected]>
---
 block/blk-mq.c         |  6 ------
 block/blk-mq.h         |  9 ---------
 include/linux/blk-mq.h | 15 ++++++++++++++-
 3 files changed, 14 insertions(+), 16 deletions(-)
block/blk-mq.c +0 -6
index c92ce06fd565..7afd1c925fa8 100644
@@ -619,12 +619,6 @@ void blk_mq_complete_request(struct request *rq)
 }
 EXPORT_SYMBOL(blk_mq_complete_request);
 
-int blk_mq_request_started(struct request *rq)
-{
-	return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
-}
-EXPORT_SYMBOL_GPL(blk_mq_request_started);
-
 void blk_mq_start_request(struct request *rq)
 {
 	struct request_queue *q = rq->q;
block/blk-mq.h +0 -9
index 9497b47e2526..18bc448b61a3 100644
@@ -90,15 +90,6 @@ extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
 
 void blk_mq_release(struct request_queue *q);
 
-/**
- * blk_mq_rq_state() - read the current MQ_RQ_* state of a request
- * @rq: target request.
- */
-static inline enum mq_rq_state blk_mq_rq_state(struct request *rq)
-{
-	return READ_ONCE(rq->state);
-}
-
 static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q,
 					   unsigned int cpu)
 {
include/linux/blk-mq.h +14 -1
index 1da59c16f637..cc0359b83fb8 100644
@@ -250,7 +250,6 @@ static inline u16 blk_mq_unique_tag_to_tag(u32 unique_tag)
 }
 
 
-int blk_mq_request_started(struct request *rq);
 void blk_mq_start_request(struct request *rq);
 void blk_mq_end_request(struct request *rq, blk_status_t error);
 void __blk_mq_end_request(struct request *rq, blk_status_t error);
@@ -303,6 +302,20 @@ static inline bool blk_mq_mark_complete(struct request *rq)
 			MQ_RQ_IN_FLIGHT;
 }
 
+/**
+ * blk_mq_rq_state() - read the current MQ_RQ_* state of a request
+ * @rq: target request.
+ */
+static inline enum mq_rq_state blk_mq_rq_state(struct request *rq)
+{
+	return READ_ONCE(rq->state);
+}
+
+static inline int blk_mq_request_started(struct request *rq)
+{
+	return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
+}
+
 /*
  * Driver command data is immediately after the request. So subtract request
  * size to get back to the original request, add request size to get the PDU.
Signature · 1 line
2.9.5
author
#3 lore raw

PATCH v2 2/2 blk-mq: fix blk_mq_tagset_busy_iter

In reply to Ming Lei

Commit d250bf4e776ff09d5("blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter") uses 'blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT' to replace 'blk_mq_request_started(req)', this way is wrong, and causes lots of test system hang during booting.

Fix the issue by using blk_mq_request_started(req) inside bt_tags_iter().

Fixes d250bf4e776ff09d5 ("blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter")
Cc Josef Bacik <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Mark Brown <[email protected]>
Cc Matt Hart <[email protected]>
Cc Johannes Thumshirn <[email protected]>
Cc John Garry <[email protected]>
Cc Hannes Reinecke <[email protected]>,
Cc "Martin K. Petersen" <[email protected]>,
Cc James Bottomley <[email protected]>
---
 block/blk-mq-tag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq-tag.c +1 -1
index 09b2ee6694fb..3de0836163c2 100644
@@ -271,7 +271,7 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)
 	 * test and set the bit before assining ->rqs[].
 	 */
 	rq = tags->rqs[bitnr];
-	if (rq && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
+	if (rq && blk_mq_request_started(rq))
 		iter_data->fn(rq, iter_data->data, reserved);
 
 	return true;
Signature · 1 line
2.9.5
Tested-by on v2 2/2
#4 lore raw

Re: [PATCH V2 2/2] blk-mq: fix blk_mq_tagset_busy_iter

Quoted 7 lines · Ming Lei

Commit d250bf4e776ff09d5("blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter") uses 'blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT' to replace 'blk_mq_request_started(req)', this way is wrong, and causes lots of test system hang during booting.

Fix the issue by using blk_mq_request_started(req) inside bt_tags_iter().

Quoted 16 lines
Fixes d250bf4e776ff09d5 ("blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter")
Cc Josef Bacik <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Mark Brown <[email protected]>
Cc Matt Hart <[email protected]>
Cc Johannes Thumshirn <[email protected]>
Cc John Garry <[email protected]>
Cc Hannes Reinecke <[email protected]>,
Cc "Martin K. Petersen" <[email protected]>,
Cc James Bottomley <[email protected]>

Test builds (with both patches applied):

Building mips:malta_defconfig:nosmp ... running ..... passed
Building mips:malta_defconfig:smp ... running ..... passed
Building x86_64:q35:Broadwell-noTSX:defconfig:smp:sata:rootfs ... running ..... passed Building x86_64:q35:IvyBridge:defconfig:smp:nvme:rootfs ... running ..... passed Building x86_64:q35:SandyBridge:defconfig:smp:usb:rootfs ... running ...... passed Building x86_64:q35:Haswell:defconfig:smp:usb-uas:rootfs ... running ...... passed Building x86_64:q35:Skylake-Client:defconfig:smp:mmc:rootfs ... running ...... passed Building x86_64:q35:Conroe:defconfig:smp:scsi[DC395]:rootfs ... running ....... passed Building x86_64:q35:Nehalem:defconfig:smp:scsi[AM53C974]:rootfs ... running ....... passed Building x86_64:q35:Westmere-IBRS:defconfig:smp:scsi[53C810]:rootfs ... running ...... passed Building x86_64:q35:Skylake-Server:defconfig:smp:scsi[53C895A]:rootfs ... running ...... passed Building x86_64:pc:EPYC:defconfig:smp:scsi[MEGASAS]:rootfs ... running ...... passed Building x86_64:q35:EPYC-IBPB:defconfig:smp:scsi[MEGASAS2]:rootfs ... running ..... passed Building x86_64:q35:Opteron_G5:defconfig:smp:scsi[FUSION]:rootfs ... running ..... passed Building x86_64:pc:phenom:defconfig:smp:initrd ... running ..... passed
Building x86_64:q35:Opteron_G1:defconfig:smp:initrd ... running ..... passed Building x86_64:pc:Opteron_G2:defconfig:smp:sata:rootfs ... running ..... passed Building x86_64:q35:core2duo:defconfig:smp:usb:rootfs ... running ...... passed Building x86_64:pc:Opteron_G3:defconfig:nosmp:usb:rootfs ... running ....... passed Building x86_64:q35:Opteron_G4:defconfig:nosmp:sata:rootfs ... running ...... passed

Guenter

Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH V2 2/2] blk-mq: fix blk_mq_tagset_busy_iter

In reply to Ming Lei
Quoted 1 line · Ming Lei

Commit d250bf4e776ff09d5("blk-mq: only iterate over inflight requ=

ests

Quoted 1 line

in blk_mq_tagset_busy_iter") uses 'blk_mq_

-rq_state(rq) == MQ_RQ_IN_FLIGHT'

Quoted 1 line

to replace 'blk_mq_request_started(req)', this way is wro=

ng, and causes

Quoted 3 lines

lots of test system hang during booting.
=20
Fix the issue by using blk_mq_request_started(req) inside=

bt_tags_iter().

That's a good catch. Hence:

maintainer
#6 lore raw
In reply to Ming Lei
Quoted 8 lines · Ming Lei

Hi Jens,

The two patches fixes boot hang issue in lots of test vm system. And the cause is in blk_mq_tagset_busy_iter().

V2:
- move blk_mq_request_started() into header file as suggested by James

I'd be fine with moving that into a header, if the target of this was 4.19. But it's not, so there's absolutely no point to include that in this series.

I'm going to apply 2/2 for 4.18.

Signature · 1 line
Jens Axboe