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 6A060C6FA92 for ; Fri, 23 Sep 2022 04:22:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C776380008; Fri, 23 Sep 2022 00:22:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C004780007; Fri, 23 Sep 2022 00:22:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A797180008; Fri, 23 Sep 2022 00:22:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 93CF080007 for ; Fri, 23 Sep 2022 00:22:37 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6135780221 for ; Fri, 23 Sep 2022 04:22:37 +0000 (UTC) X-FDA: 79942053954.23.8682BAC Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) by imf14.hostedemail.com (Postfix) with ESMTP id CEF0C10000C for ; Fri, 23 Sep 2022 04:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=+/f7rQqEMYVFzSTEHMH7lncMBYm3L3Qg9syncr2dQT4=; b=jSbZR1B9zaw3IUb4LnQOM9P7W9 LWABTG8h+HtJQW6NV9vx5y/twluuZRVUmrCCh7vfod5xUnH84BVWs3C53GmfJdKih08M3KET39+OV /DiwEDkwJYzJ9OFj5CRG/i10mcWEy2Dsxq5VdNfJas7JLzHoMtlNNj5Z7Bn0xYwAypvZmx1V6kU9/ TYTUGLCLztQVdWXDEkeoLoB/T7psEB/BVae2Ro8rnO1vWb+4MO3iEITxpiFWCwjJGZNYhJpiYo6Dg 71aOuNRb/D4sTZm3Odz8kSPVcikla0nUG3tCH7dRS5kfySFrrRtCGJ8TvsiqtlJKtx/CiIo4RWlI4 P6BRgcFw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1obaCf-002fhY-2m; Fri, 23 Sep 2022 04:22:17 +0000 Date: Fri, 23 Sep 2022 05:22:17 +0100 From: Al Viro To: Christoph Hellwig Cc: Jan Kara , John Hubbard , Andrew Morton , Jens Axboe , Miklos Szeredi , "Darrick J . Wong" , Trond Myklebust , Anna Schumaker , David Hildenbrand , Logan Gunthorpe , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, LKML Subject: Re: [PATCH v2 4/7] iov_iter: new iov_iter_pin_pages*() routines Message-ID: References: <103fe662-3dc8-35cb-1a68-dda8af95c518@nvidia.com> <20220906102106.q23ovgyjyrsnbhkp@quack3> <20220914145233.cyeljaku4egeu4x2@quack3> <20220915081625.6a72nza6yq4l5etp@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.org.uk header.s=zeniv-20220401 header.b=jSbZR1B9; spf=none (imf14.hostedemail.com: domain of viro@ftp.linux.org.uk has no SPF policy when checking 62.89.141.173) smtp.mailfrom=viro@ftp.linux.org.uk; dmarc=pass (policy=none) header.from=zeniv.linux.org.uk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663906956; a=rsa-sha256; cv=none; b=3c0tOshbNzEX0V/RO/d7fbNLY/laB6TUaeAuDWCt5ym72NNjqrPZnwEb2zX4rlOB+LFbr9 QcGqwmeYxMlSn5w8yzZcKfnJcClMYb4Jo3jhr3Nc2jVfrgQsYLVRME7FIAjZbqtIx/lNps VTYQ6B45P/oPqmD/mYgLo1KGAvTbEu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663906956; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+/f7rQqEMYVFzSTEHMH7lncMBYm3L3Qg9syncr2dQT4=; b=u959yGEq6M5s9Zq9nHYo7XXqjdCjBn+e63adYSVcmq+zL6aL0tUDOR95axPadBd2+V75Uv ry+Mueqy0vX231nU/Nt4aPQ8zpCAcGil2385RBCUoA6HV+McGWZfTa7YXzS9WqLTK3pl6X nINjFO814UOoqlN+Lek4mcY5br7ix08= Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.org.uk header.s=zeniv-20220401 header.b=jSbZR1B9; spf=none (imf14.hostedemail.com: domain of viro@ftp.linux.org.uk has no SPF policy when checking 62.89.141.173) smtp.mailfrom=viro@ftp.linux.org.uk; dmarc=pass (policy=none) header.from=zeniv.linux.org.uk X-Rspam-User: X-Stat-Signature: 7ixf755mj5g8x1nik4i5ham4mx1ndfjr X-Rspamd-Queue-Id: CEF0C10000C X-Rspamd-Server: rspam09 X-HE-Tag: 1663906955-574681 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 Thu, Sep 22, 2022 at 07:38:25AM -0700, Christoph Hellwig wrote: > On Thu, Sep 22, 2022 at 03:22:48AM +0100, Al Viro wrote: > > What I'd like to have is the understanding of the places where we drop > > the references acquired by iov_iter_get_pages(). How do we decide > > whether to unpin? > > Add a iov_iter_unpin_pages that does the right thing based on the > type. (block will need a modified copy of it as it doesn't keep > the pages array around, but logic will be the same). Huh? You want to keep the type (+ direction) of iov_iter in any structure a page reference coming from iov_iter_get_pages might end up in? IDGI... BTW, speaking of lifetime rules - am I right assuming that fd_execute_rw() does IO on pages of the scatterlist passed to it? Where are they getting dropped and what guarantees that IO is complete by that point? The reason I'm asking is that here you have an ITER_BVEC possibly fed to __blkdev_direct_IO_async(), with its if (iov_iter_is_bvec(iter)) { /* * Users don't rely on the iterator being in any particular * state for async I/O returning -EIOCBQUEUED, hence we can * avoid expensive iov_iter_advance(). Bypass * bio_iov_iter_get_pages() and set the bvec directly. */ bio_iov_bvec_set(bio, iter); which does *not* grab the page referneces. Sure, bio_release_pages() knows to leave those alone and doesn't drop anything. However, what is the mechanism preventing the pages getting freed before the IO completion in this case?