From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A15E9C433F5 for ; Fri, 15 Apr 2022 05:18:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 190AE6B0080; Fri, 15 Apr 2022 01:18:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 141C56B0081; Fri, 15 Apr 2022 01:18:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0084F6B0082; Fri, 15 Apr 2022 01:18:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id DF2E46B0080 for ; Fri, 15 Apr 2022 01:18:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 91116A89A0 for ; Fri, 15 Apr 2022 05:18:49 +0000 (UTC) X-FDA: 79357958778.30.52FFEA2 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf23.hostedemail.com (Postfix) with ESMTP id EBCD6140006 for ; Fri, 15 Apr 2022 05:18:48 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 1808D68B05; Fri, 15 Apr 2022 07:18:45 +0200 (CEST) Date: Fri, 15 Apr 2022 07:18:44 +0200 From: Christoph Hellwig To: Ming Lei Cc: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-mm@kvack.org, linux-xfs@vger.kernel.org, Changhui Zhong Subject: Re: [PATCH V2] block: avoid io timeout in case of sync polled dio Message-ID: <20220415051844.GA22762@lst.de> References: <20220415034703.2081695-1-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220415034703.2081695-1-ming.lei@redhat.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EBCD6140006 X-Stat-Signature: 9z8sk4yomqn85btep4um6595knoftm5e Authentication-Results: imf23.hostedemail.com; dkim=none; spf=none (imf23.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none X-HE-Tag: 1649999928-673692 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Apr 15, 2022 at 11:47:03AM +0800, Ming Lei wrote: > + /* make sure the bio is issued before polling */ > + if (bio.bi_opf & REQ_POLLED) > + blk_flush_plug(current->plug, false); I still think the core code should handle this. Without that we'd need to export the blk_flush_plug for anything that would want to poll bios from modules, in addition to it generally being a mess. See a proposed patch for that below. I'd also split the flush aspect from the poll aspect into two patches. > + if (bio.bi_opf & REQ_POLLED) > + bio_poll(&bio, NULL, 0); > + else > blk_io_schedule(); Instead of this duplicate logic everywhere I'd just make bio_boll call blk_io_schedule for the !REQ_POLLED case and simplify all the callers. > + if (dio->submit.poll_bio && > + (dio->submit.poll_bio->bi_opf & > + REQ_POLLED)) This indentation looks awfull,=EE=80=80normal would be: if (dio->submit.poll_bio && (dio->submit.poll_bio->bi_opf & REQ_POLLED)) --- >From 08ff61b0142eb708fc384cf867c72175561d974a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 15 Apr 2022 07:15:42 +0200 Subject: blk-mq: don't plug for synchronously polled requests For synchronous polling to work, the bio must be issued to the driver fro= m the submit_bio call, otherwise ->bi_cookie won't be set. Based on a patch from Ming Lei. Reported-by: Changhui Zhong Signed-off-by: Christoph Hellwig --- block/blk-mq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index ed3ed86f7dd24..bcc7e3d11296c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2851,7 +2851,13 @@ void blk_mq_submit_bio(struct bio *bio) return; } =20 - if (plug) + /* + * We can't plug for synchronously polled submissions, otherwise + * bio->bi_cookie won't be set directly after submission, which is the + * indicator used by the submitter to check if a bio needs polling. + */ + if (plug && + (rq->bio->bi_opf & (REQ_POLLED | REQ_NOWAIT)) !=3D REQ_POLLED) blk_add_rq_to_plug(plug, rq); else if ((rq->rq_flags & RQF_ELV) || (rq->mq_hctx->dispatch_busy && --=20 2.30.2