* [PATCH V2 0/3] blk-mq: misc fixes
@ 2021-11-02 15:36 Ming Lei
2021-11-02 15:36 ` [PATCH V2 1/3] blk-mq: only try to run plug merge if request has same queue with incoming bio Ming Lei
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Ming Lei @ 2021-11-02 15:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei
Hello,
Here are 3 small fixes against latest linus tree.
V2:
- move batched update into blk_mq_flush_tag_batch() as suggested by
Jens, 3/3
Ming Lei (3):
blk-mq: only try to run plug merge if request has same queue with
incoming bio
blk-mq: add RQF_ELV debug entry
blk-mq: update hctx->nr_active in blk_mq_end_request_batch()
block/blk-merge.c | 6 ++++--
block/blk-mq-debugfs.c | 1 +
block/blk-mq.c | 7 +++++++
block/blk-mq.h | 12 +++++++++---
4 files changed, 21 insertions(+), 5 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 1/3] blk-mq: only try to run plug merge if request has same queue with incoming bio
2021-11-02 15:36 [PATCH V2 0/3] blk-mq: misc fixes Ming Lei
@ 2021-11-02 15:36 ` Ming Lei
2021-11-02 15:36 ` [PATCH V2 2/3] blk-mq: add RQF_ELV debug entry Ming Lei
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Ming Lei @ 2021-11-02 15:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei
It is obvious that io merge can't be done between two different queues, so
just try to run io merge in case of same queue.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-merge.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index df69f4bb7717..893c1a60b701 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -1101,9 +1101,11 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
* the same queue, there should be only one such rq in a queue
*/
*same_queue_rq = true;
+
+ if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
+ BIO_MERGE_OK)
+ return true;
}
- if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) == BIO_MERGE_OK)
- return true;
return false;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 2/3] blk-mq: add RQF_ELV debug entry
2021-11-02 15:36 [PATCH V2 0/3] blk-mq: misc fixes Ming Lei
2021-11-02 15:36 ` [PATCH V2 1/3] blk-mq: only try to run plug merge if request has same queue with incoming bio Ming Lei
@ 2021-11-02 15:36 ` Ming Lei
2021-11-02 15:36 ` [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch() Ming Lei
2021-11-02 16:00 ` [PATCH V2 0/3] blk-mq: misc fixes Jens Axboe
3 siblings, 0 replies; 7+ messages in thread
From: Ming Lei @ 2021-11-02 15:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei
Looks it is missed so add it.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq-debugfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index f5076c173477..4f2cf8399f3d 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -308,6 +308,7 @@ static const char *const rqf_name[] = {
RQF_NAME(SPECIAL_PAYLOAD),
RQF_NAME(ZONE_WRITE_LOCKED),
RQF_NAME(MQ_POLL_SLEPT),
+ RQF_NAME(ELV),
};
#undef RQF_NAME
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch()
2021-11-02 15:36 [PATCH V2 0/3] blk-mq: misc fixes Ming Lei
2021-11-02 15:36 ` [PATCH V2 1/3] blk-mq: only try to run plug merge if request has same queue with incoming bio Ming Lei
2021-11-02 15:36 ` [PATCH V2 2/3] blk-mq: add RQF_ELV debug entry Ming Lei
@ 2021-11-02 15:36 ` Ming Lei
2021-11-02 22:43 ` Shinichiro Kawasaki
2021-11-02 16:00 ` [PATCH V2 0/3] blk-mq: misc fixes Jens Axboe
3 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2021-11-02 15:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei, Shinichiro Kawasaki
In case of shared tags and none io sched, batched completion still may
be run into, and hctx->nr_active is accounted when getting driver tag,
so it has to be updated in blk_mq_end_request_batch().
Otherwise, hctx->nr_active may become same with queue depth, then
hctx_may_queue() always return false, then io hang is caused.
Fixes the issue by updating the counter in batched way.
Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fixes: f794f3351f26 ("block: add support for blk_mq_end_request_batch()")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq.c | 7 +++++++
block/blk-mq.h | 12 +++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 07eb1412760b..2a2c57c98bbd 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -815,6 +815,13 @@ static inline void blk_mq_flush_tag_batch(struct blk_mq_hw_ctx *hctx,
{
struct request_queue *q = hctx->queue;
+ /*
+ * All requests should have been marked as RQF_MQ_INFLIGHT, so
+ * update hctx->nr_active in batch
+ */
+ if (hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED)
+ __blk_mq_sub_active_requests(hctx, nr_tags);
+
blk_mq_put_tags(hctx->tags, tag_array, nr_tags);
percpu_ref_put_many(&q->q_usage_counter, nr_tags);
}
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 28859fc5faee..cb0b5482ca5e 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -225,12 +225,18 @@ static inline void __blk_mq_inc_active_requests(struct blk_mq_hw_ctx *hctx)
atomic_inc(&hctx->nr_active);
}
-static inline void __blk_mq_dec_active_requests(struct blk_mq_hw_ctx *hctx)
+static inline void __blk_mq_sub_active_requests(struct blk_mq_hw_ctx *hctx,
+ int val)
{
if (blk_mq_is_shared_tags(hctx->flags))
- atomic_dec(&hctx->queue->nr_active_requests_shared_tags);
+ atomic_sub(val, &hctx->queue->nr_active_requests_shared_tags);
else
- atomic_dec(&hctx->nr_active);
+ atomic_sub(val, &hctx->nr_active);
+}
+
+static inline void __blk_mq_dec_active_requests(struct blk_mq_hw_ctx *hctx)
+{
+ __blk_mq_sub_active_requests(hctx, 1);
}
static inline int __blk_mq_active_requests(struct blk_mq_hw_ctx *hctx)
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2 0/3] blk-mq: misc fixes
2021-11-02 15:36 [PATCH V2 0/3] blk-mq: misc fixes Ming Lei
` (2 preceding siblings ...)
2021-11-02 15:36 ` [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch() Ming Lei
@ 2021-11-02 16:00 ` Jens Axboe
3 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2021-11-02 16:00 UTC (permalink / raw)
To: Ming Lei; +Cc: linux-block
On 11/2/21 9:36 AM, Ming Lei wrote:
> Hello,
>
> Here are 3 small fixes against latest linus tree.
>
> V2:
> - move batched update into blk_mq_flush_tag_batch() as suggested by
> Jens, 3/3
Thanks Ming, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch()
2021-11-02 15:36 ` [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch() Ming Lei
@ 2021-11-02 22:43 ` Shinichiro Kawasaki
2021-11-02 22:44 ` Jens Axboe
0 siblings, 1 reply; 7+ messages in thread
From: Shinichiro Kawasaki @ 2021-11-02 22:43 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, linux-block, Damien Le Moal, Keith Busch
On Nov 02, 2021 / 23:36, Ming Lei wrote:
> In case of shared tags and none io sched, batched completion still may
> be run into, and hctx->nr_active is accounted when getting driver tag,
> so it has to be updated in blk_mq_end_request_batch().
>
> Otherwise, hctx->nr_active may become same with queue depth, then
> hctx_may_queue() always return false, then io hang is caused.
>
> Fixes the issue by updating the counter in batched way.
>
> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Fixes: f794f3351f26 ("block: add support for blk_mq_end_request_batch()")
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
Ming, thank you very much. I have confirmed that the blktests block/005 hang
disappears using NVMe devices with two namespaces.
Though this patch is already queued up to for-5.16/block, in case it is still
meaningful:
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
--
Best Regards,
Shin'ichiro Kawasaki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch()
2021-11-02 22:43 ` Shinichiro Kawasaki
@ 2021-11-02 22:44 ` Jens Axboe
0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2021-11-02 22:44 UTC (permalink / raw)
To: Shinichiro Kawasaki, Ming Lei; +Cc: linux-block, Damien Le Moal, Keith Busch
On 11/2/21 4:43 PM, Shinichiro Kawasaki wrote:
> On Nov 02, 2021 / 23:36, Ming Lei wrote:
>> In case of shared tags and none io sched, batched completion still may
>> be run into, and hctx->nr_active is accounted when getting driver tag,
>> so it has to be updated in blk_mq_end_request_batch().
>>
>> Otherwise, hctx->nr_active may become same with queue depth, then
>> hctx_may_queue() always return false, then io hang is caused.
>>
>> Fixes the issue by updating the counter in batched way.
>>
>> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>> Fixes: f794f3351f26 ("block: add support for blk_mq_end_request_batch()")
>> Signed-off-by: Ming Lei <ming.lei@redhat.com>
>
> Ming, thank you very much. I have confirmed that the blktests block/005 hang
> disappears using NVMe devices with two namespaces.
>
> Though this patch is already queued up to for-5.16/block, in case it is still
> meaningful:
>
> Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Testing is _always_ meaningful! So thanks for doing that, and reporting it in
the first place. The patch has been queued up this morning for 5.16.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-02 22:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 15:36 [PATCH V2 0/3] blk-mq: misc fixes Ming Lei
2021-11-02 15:36 ` [PATCH V2 1/3] blk-mq: only try to run plug merge if request has same queue with incoming bio Ming Lei
2021-11-02 15:36 ` [PATCH V2 2/3] blk-mq: add RQF_ELV debug entry Ming Lei
2021-11-02 15:36 ` [PATCH V2 3/3] blk-mq: update hctx->nr_active in blk_mq_end_request_batch() Ming Lei
2021-11-02 22:43 ` Shinichiro Kawasaki
2021-11-02 22:44 ` Jens Axboe
2021-11-02 16:00 ` [PATCH V2 0/3] blk-mq: misc fixes Jens Axboe
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).