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 803A2C433EF for ; Sat, 16 Apr 2022 09:03:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3E8A6B0072; Sat, 16 Apr 2022 05:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC6D56B0073; Sat, 16 Apr 2022 05:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8EF76B0074; Sat, 16 Apr 2022 05:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 941756B0072 for ; Sat, 16 Apr 2022 05:03:51 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5597C23EAA for ; Sat, 16 Apr 2022 09:03:51 +0000 (UTC) X-FDA: 79362154662.17.A8BDF29 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 8C26C1C0002 for ; Sat, 16 Apr 2022 09:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650099830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+F3IclGpN6LG2HX4GRtWaYgRDtghcyGDVhwRl4OE650=; b=iVjjArRFHk56mN2v8I1fHOpLAi0GHSzPwPD3GOS8Dp7/XEaI8i8XQ7pZgQtf6UqfoFnLhp bIvDcROI33s79fmER4KpLE9HxhwK37u0/tSQ7mriCt5PCe8eyn/8vCSN8X/qZOL7DLKpus zLVuwBivZCJi5roTWH1OAnYQNOpn5O0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-nSxqUU0bPB-XJ4TIJrd2Sg-1; Sat, 16 Apr 2022 05:03:46 -0400 X-MC-Unique: nSxqUU0bPB-XJ4TIJrd2Sg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 10F80185A79C; Sat, 16 Apr 2022 09:03:46 +0000 (UTC) Received: from T590 (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77813145D392; Sat, 16 Apr 2022 09:03:40 +0000 (UTC) Date: Sat, 16 Apr 2022 17:03:35 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , linux-block@vger.kernel.org, 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: References: <20220415034703.2081695-1-ming.lei@redhat.com> <20220415051844.GA22762@lst.de> <20220416054913.GA7405@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220416054913.GA7405@lst.de> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8C26C1C0002 X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iVjjArRF; spf=none (imf18.hostedemail.com: domain of ming.lei@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: a6etpsbnp3z3tk7qyoij9nfkcgokfr3f X-HE-Tag: 1650099830-761606 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 Sat, Apr 16, 2022 at 07:49:13AM +0200, Christoph Hellwig wrote: > On Fri, Apr 15, 2022 at 07:00:37PM +0800, Ming Lei wrote: > > On Fri, Apr 15, 2022 at 07:18:44AM +0200, Christoph Hellwig wrote: > > > 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 > > > > So far there isn't such usage yet. dm calls bio_poll() in ->iopoll(), > > and its caller(io_uring) will finish the plug. > > Yes. But not doing this automatically also means you keep easily > forgetting callsites. For example iomap still does not flush the plug > in your patch. It is reasonable for flush user(usually submission) to be responsible for finishing/flushing plug. iomap is one good example to show this point, since it does flush the plug before call bio_poll(), see __iomap_dio_rw(). > > > > 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. > > > > bio_poll() may be called with rcu read lock held, so I'd suggest to > > not mix the two together. > > Ok, makes sense. > > > > > > > > + if (dio->submit.poll_bio && > > > > + (dio->submit.poll_bio->bi_opf & > > > > + REQ_POLLED)) > > > > > > This indentation looks awfull,normal would be: > > > > > > if (dio->submit.poll_bio && > > > (dio->submit.poll_bio->bi_opf & REQ_POLLED)) > > > > That follows the indentation style of fs/iomap/direct-io.c for break in > > 'if'. > > It doesn't. Just look at the conditional you replaced for example :) OK, I will change to your style. > > > > + /* > > > + * 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)) != REQ_POLLED) > > > blk_add_rq_to_plug(plug, rq); > > > else if ((rq->rq_flags & RQF_ELV) || > > > (rq->mq_hctx->dispatch_busy && > > > > It is nothing to do with REQ_NOWAIT. sync polled dio can be marked as > > REQ_NOWAIT by userspace too. If '--nowait=1' is added in the fio > > reproducer, io timeout is triggered too. > > True. So I guess we'll need a new flag to distinguish the cases. If there will be more such kind of poll usage in kernel, I think it is fine to add the flag, but so far all the three aren't used very often. Thanks, Ming