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 56EC7C38145 for ; Wed, 7 Sep 2022 08:50:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAE6B6B0073; Wed, 7 Sep 2022 04:50:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C37316B0074; Wed, 7 Sep 2022 04:50:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFEDF8D0002; Wed, 7 Sep 2022 04:50:21 -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 9D6E86B0073 for ; Wed, 7 Sep 2022 04:50:21 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 711111A042B for ; Wed, 7 Sep 2022 08:50:21 +0000 (UTC) X-FDA: 79884667842.15.9D0959D Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id 2E0AD180068 for ; Wed, 7 Sep 2022 08:50:21 +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=/OVlAwW7sTMujMAdfroN1GdwN81L832uh1HMrI/nvGo=; b=asGZyz3lnIp+c/31yhqNB3FuPy f6fsq8p0L7wSMvyxGmWAQ7k7NZXA1eW8Fz4M0BSsCva1X4pxrgUa0Jj5EZlR2l9B+vXdgDCPTT/ei hv27ApJ2tQ1Ap90kCx4akyi+6uLb9NhAhoyT9jCkH1RmNwcPq9Ca6MseOuKJ0IMa6ti04OfbSe/JT DHTLaZJKlRvDjpAARCk/hWwaebAM/2UdDrmcSqemR/RFF5H6Oz786lTv/ItQr3quy73LaWz0rz4Eb dGT3Cmwwf81BAHOyPBy3bfIK7zHFQ3qQTzQlvU5XEaKcPTYksp4/xPJnO9DpwqIAtcbV156GaV/b7 Cx8x3Nng==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVql9-004Ux0-J9; Wed, 07 Sep 2022 08:50:11 +0000 Date: Wed, 7 Sep 2022 01:50:11 -0700 From: Christoph Hellwig To: John Hubbard Cc: Christoph Hellwig , Andrew Morton , Jens Axboe , Alexander Viro , Miklos Szeredi , "Darrick J . Wong" , Trond Myklebust , Anna Schumaker , Jan Kara , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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=1662540621; a=rsa-sha256; cv=none; b=WQtSxBiQhfPiO538Rr+ZOZCZNm7jYdWbLGBmPG3f3Mwbg0w1mZc+6xvFkVdNUDP0FucyUA MSwVDtTSTuCyhSnaLFwWFezm25xKSvWp/LhP8JR+mMCuI3bPcfOYuEFdGc56BDmCDyXymY NH71Oxy5XUr0O5S6rYYKf/qIW6YBLa0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=asGZyz3l; spf=none (imf06.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=1662540621; 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=/OVlAwW7sTMujMAdfroN1GdwN81L832uh1HMrI/nvGo=; b=nReT6fCisLamhEOTVhn7NSWoDS+LcRZSQLMtybgrBSGFlzaSb/7SLzShe2OqzwIorqZAwZ ZCxa+qr1NQf0w7nR3+ExzEzjc43h7FsqEsoenGh4BkwnYhXXlZetpy5MZhqR0YMygeRZWw WgBq5hhsRcvLLGg/k5BitYpDB/w6+No= X-Stat-Signature: zrbtunuemfpuaznq38i1o7tufntdq9z9 X-Rspamd-Queue-Id: 2E0AD180068 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=asGZyz3l; spf=none (imf06.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-Rspamd-Server: rspam01 X-Rspam-User: X-HE-Tag: 1662540621-389162 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:58:59AM -0700, John Hubbard 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. > > In order to do that, one would need to be confident that such bvec and kvec > pages do not get passed down to bio_release_pages() (or the new > bio_unpin_pages()). Also, I'm missing a key point, because today bvec pages get > a get_page() reference from __iov_iter_get_pages_alloc(). If I just skip > that, then the get/put calls are unbalanced... Except that for the most relevant callers (bdev and iomap) we never end up in __iov_iter_get_pages_alloc. What I suggest is that, with the move to the pin helper, we codify that logic. For callers of the bio_iov_iter_pin_pages helper, the corresponding bio_unpin_pages helper will encapsulate that logic. For direct calls to iov_iter_pin_pages, we should add a iov_iter_unpin_pages helper that also encapsulates the logic. The beauty is that this means the caller itself does not have to care about any of thise, and the logic is in one (well two due to the block special case that reuses the bio_vec array for the pages space) place. > I can just hear Al Viro repeating his points about splice() and vmsplice(), > heh. :) splice does take these references before calling into the file system (see my reply to Jan).