diff mbox series

[3/3] blk-mq: directly poll requests

Message ID 20230322002350.4038048-4-kbusch@meta.com (mailing list archive)
State New, archived
Headers show
Series nvme fabrics polling fixes | expand

Commit Message

Keith Busch March 22, 2023, 12:23 a.m. UTC
From: Keith Busch <kbusch@kernel.org>

Polling needs a bio with a valid bi_bdev, but neither of those are
guaranteed for polled driver requests. Make request based polling use
directly use blk-mq's polling function.

When executing a request from a polled hctx, we know the request's
cookie, and that it's from a live multi-queue that supports polling, so
we can safely skip everything that bio_poll provides.

Link: http://lists.infradead.org/pipermail/linux-nvme/2023-March/038340.html
Reported-by: Martin Belanger <Martin.Belanger@dell.com>
Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 block/blk-mq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Sagi Grimberg March 22, 2023, 7:36 a.m. UTC | #1
Nice.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Christoph Hellwig March 22, 2023, 8:23 a.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Daniel Wagner March 22, 2023, 8:37 a.m. UTC | #3
On Tue, Mar 21, 2023 at 05:23:50PM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> Polling needs a bio with a valid bi_bdev, but neither of those are
> guaranteed for polled driver requests. Make request based polling use
> directly use blk-mq's polling function.
> 
> When executing a request from a polled hctx, we know the request's
> cookie, and that it's from a live multi-queue that supports polling, so
> we can safely skip everything that bio_poll provides.
> 
> Link: http://lists.infradead.org/pipermail/linux-nvme/2023-March/038340.html
> Reported-by: Martin Belanger <Martin.Belanger@dell.com>
> Reported-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Keith Busch <kbusch@kernel.org>

I've tested the whole series and this patch alone with rdma and tcp.

Tested-by: Daniel Wagner <dwagner@suse.de>
Revieded-by: Daniel Wagner <dwagner@suse.de>
Sagi Grimberg March 22, 2023, 9:08 a.m. UTC | #4
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

This should go in unrelated to the rest of the series.
Chaitanya Kulkarni March 22, 2023, 6:16 p.m. UTC | #5
On 3/22/23 01:37, Daniel Wagner wrote:
> On Tue, Mar 21, 2023 at 05:23:50PM -0700, Keith Busch wrote:
>> From: Keith Busch <kbusch@kernel.org>
>>
>> Polling needs a bio with a valid bi_bdev, but neither of those are
>> guaranteed for polled driver requests. Make request based polling use
>> directly use blk-mq's polling function.
>>
>> When executing a request from a polled hctx, we know the request's
>> cookie, and that it's from a live multi-queue that supports polling, so
>> we can safely skip everything that bio_poll provides.
>>
>> Link: http://lists.infradead.org/pipermail/linux-nvme/2023-March/038340.html
>> Reported-by: Martin Belanger <Martin.Belanger@dell.com>
>> Reported-by: Daniel Wagner <dwagner@suse.de>
>> Signed-off-by: Keith Busch <kbusch@kernel.org>
> I've tested the whole series and this patch alone with rdma and tcp.
>
> Tested-by: Daniel Wagner <dwagner@suse.de>
> Revieded-by: Daniel Wagner <dwagner@suse.de>

Thanks Daniel, please add my tag also.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Shinichiro Kawasaki March 31, 2023, 7:57 a.m. UTC | #6
On Mar 21, 2023 / 17:23, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> Polling needs a bio with a valid bi_bdev, but neither of those are
> guaranteed for polled driver requests. Make request based polling use
> directly use blk-mq's polling function.
> 
> When executing a request from a polled hctx, we know the request's
> cookie, and that it's from a live multi-queue that supports polling, so
> we can safely skip everything that bio_poll provides.
> 
> Link: http://lists.infradead.org/pipermail/linux-nvme/2023-March/038340.html
> Reported-by: Martin Belanger <Martin.Belanger@dell.com>
> Reported-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Keith Busch <kbusch@kernel.org>

I also tested this patch with rdma and tcp transports using the blktests patches
by Daniel [1]. It fixes the failure, and I did not observe test hangs. Good.

Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

I suggest to add the "Cc: stable@kernel.org" tag also. Without this fix patch,
the new blktests test case causes test process hang or test system hang on
stable kernel versions 6.1.0 and 6.2.0. I confirmed the fix patch avoids the
hangs on those stable kernel versions (This patch can not be applied the kernel
to v5.15.105 due to conflicts).

[1] https://lore.kernel.org/linux-block/20230329090202.8351-1-dwagner@suse.de/
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4e30459df8151..932d2e95392e6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1334,8 +1334,6 @@  bool blk_rq_is_poll(struct request *rq)
 		return false;
 	if (rq->mq_hctx->type != HCTX_TYPE_POLL)
 		return false;
-	if (WARN_ON_ONCE(!rq->bio))
-		return false;
 	return true;
 }
 EXPORT_SYMBOL_GPL(blk_rq_is_poll);
@@ -1343,7 +1341,7 @@  EXPORT_SYMBOL_GPL(blk_rq_is_poll);
 static void blk_rq_poll_completion(struct request *rq, struct completion *wait)
 {
 	do {
-		bio_poll(rq->bio, NULL, 0);
+		blk_mq_poll(rq->q, blk_rq_to_qc(rq), NULL, 0);
 		cond_resched();
 	} while (!completion_done(wait));
 }