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 F1231C38145 for ; Wed, 7 Sep 2022 08:45:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F6706B0073; Wed, 7 Sep 2022 04:45:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A6286B0074; Wed, 7 Sep 2022 04:45:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46ECE8D0002; Wed, 7 Sep 2022 04:45:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 38F1E6B0073 for ; Wed, 7 Sep 2022 04:45:49 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 09BE21608C6 for ; Wed, 7 Sep 2022 08:45:49 +0000 (UTC) X-FDA: 79884656418.27.2120594 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id C084A40086 for ; Wed, 7 Sep 2022 08:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=EBn6+PekQ9HgWpOyL3HjDLpM5I9iK8a5/LWby5GXm9w=; b=oVetsvWLvH5eTqsi2zWONtOAC3 rpZ6+qvDKI37kr2ze2cMlVgkhAfvPg6uiUWsrUYR9ZcUyYQNl4xeK1t6c4whmVHD1E23Mhxgz01wR vXF5bBSal2savl00zL3GewiEwtqdPIW0eH0UH4EbDt3Wi2PxSzFltT2mdaBrlbik3gmpqAjya3jSQ NGIUR67sBaEfsENy+OvVHmXQ7qCuMwLTtqbOKQl1Wv+5Kl/t2anvwTp1DeYUFuU8DAs/eLpqyNY3y FxW4UOxkCgD0Il8Z5AF1hAzQ0cfHvx1nSsH2xsI4w6iHAzjsFq53EgVIyPzPpxzmtV9iZ+vo4btdE qjixFbYg==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVqgY-004SGZ-4V; Wed, 07 Sep 2022 08:45:26 +0000 Date: Wed, 7 Sep 2022 01:45:26 -0700 From: Christoph Hellwig To: Jan Kara Cc: Christoph Hellwig , John Hubbard , Andrew Morton , Jens Axboe , Alexander Viro , 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: <20220831041843.973026-1-jhubbard@nvidia.com> <20220831041843.973026-5-jhubbard@nvidia.com> <103fe662-3dc8-35cb-1a68-dda8af95c518@nvidia.com> <20220906102106.q23ovgyjyrsnbhkp@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220906102106.q23ovgyjyrsnbhkp@quack3> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662540348; a=rsa-sha256; cv=none; b=y411TeR4ebXAexM7F8yOuV744oLe+jMLsweMowwziUI3ZHaVa/yZgg+KVlyxUor/zUFCGA OjN5k58VvhK6lD2ABjI8PHQmeKpj/CVND0u0hhaXy8/+O+FOaXoIuZRx7ML+S8bz2Hjnyc bS3mACBI4XC4v+cuZco3wOjTgGSluic= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oVetsvWL; spf=none (imf12.hostedemail.com: domain of BATV+a7179cf3af9bc3683476+6954+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a7179cf3af9bc3683476+6954+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662540348; h=from:from: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=EBn6+PekQ9HgWpOyL3HjDLpM5I9iK8a5/LWby5GXm9w=; b=hNkA0+Og4idCGKepLFbJ5Zl5tsuMj38O2jx2nFL5k1xgRs3bMcaTmRt6rFdE8sJR21eGo6 TiAEUCVYOdBO5P+kafNazP5AuiEdtMaHxHlQWx4iPvpkkbXLkRyA+oln0Bc+bZYf5wiuL2 34qEiZWSbbTEby8AOlyMTFW3wCobCbk= X-Rspam-User: X-Rspamd-Queue-Id: C084A40086 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oVetsvWL; spf=none (imf12.hostedemail.com: domain of BATV+a7179cf3af9bc3683476+6954+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a7179cf3af9bc3683476+6954+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none X-Stat-Signature: q1myanhtz3wq6et4mqnsxwjuuu786ujb X-Rspamd-Server: rspam03 X-HE-Tag: 1662540347-749821 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 Tue, Sep 06, 2022 at 12:21:06PM +0200, Jan Kara wrote: > > For FOLL_PIN callers, never pin bvec and kvec pages: For file systems > > not acquiring a reference is obviously safe, and the other callers will > > need an audit, but I can't think of why it woul ever be unsafe. > > Are you sure about "For file systems not acquiring a reference is obviously > safe"? I can see places e.g. in orangefs, afs, etc. which create bvec iters > from pagecache pages. And then we have iter_file_splice_write() which > creates bvec from pipe pages (which can also be pagecache pages if > vmsplice() is used). So perhaps there are no lifetime issues even without > acquiring a reference (but looking at the code I would not say it is > obvious) but I definitely don't see how it would be safe to not get a pin > to signal to filesystem backing the pagecache page that there is DMA > happening to/from the page. I mean in the context of iov_iter_get_pages callers, that is direct I/O. Direct callers of iov_iter_bvec which then pass that iov to ->read_iter / ->write_iter will need to hold references (those are the references that the callers of iov_iter_get_pages rely on!).