Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8160326rwn; Wed, 14 Sep 2022 09:48:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR7kapw0U2CE1H/4hsHCsEhBFEXyFKfGa9UBc3YHcYO6YxWLvfu9Y6KQRtXKVKV0Xo+ymZuE X-Received: by 2002:a17:907:72cf:b0:780:2618:97d4 with SMTP id du15-20020a17090772cf00b00780261897d4mr3906585ejc.150.1663174132299; Wed, 14 Sep 2022 09:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663174132; cv=none; d=google.com; s=arc-20160816; b=xIn0g0bMFxKRT01IBN2TVPh+Yn8UVC+qgKxbK1uFyM2SRXr51U+1dqPwHBuI4SmmaQ 46cIGhWd3UMc1IDQf8lR4EUiCan20vFjWnR/If7maDPgKiDMvdqXqRKYX215yL919nCc a3p2yml95t+4PAJW60c7CEBcfMcwaLaUFbIauHXIS8Ppbwk6imohW4nzst/3SAiNHnPd Hvu5tz0tqKajGqyQmtLFda/YzXYqNs/RenTWhlJbSJ0VVWb1S29m32swJeBLtUG0I+CE LgbgW95IHXpnOWNVL14paHljIRbY0UDCRNV1v2KxdBHqX6q4V/HC84kCt0NiSvTg2g4f DO9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=drGd84Y88D87DtABnnd7yh6bhIO3nFxVGZfiNKSay/w=; b=KP0n0Fd/AlJptzk2wYWqJmPi8yxTWE7kCTw4GnsejDySLPtR+0agBasf9/kH9+iiug 1Jw9CaV9Acp8bNKfnZcBXGdoFNxjy5LEhCM1+mWQqatTiAqUd1YRkjTTr8jSQq3U29vQ j3bblawrIOl9Nu6u2ILU/KfOMQKqKiSJ2MnFKCkXDdAo+Emz53Vbd+ZeSDP0IKfqBEfa +prYy2O8IMC8MOt/5/Qhl5i3xhBH2Df0uUHRMDCNvqeLxABphOsBoNwebb/XnIV9De9m y1pWfa+2Tmp5vvJxSAGPf+3vV8F4+GYjdoR5ol/LBzT4hmUvG/wSLZRTNrpWu0rv+ZxB vsnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=NJ6SAfFn; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wg2-20020a17090705c200b0077edee81b40si6872975ejb.453.2022.09.14.09.48.20; Wed, 14 Sep 2022 09:48:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=NJ6SAfFn; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbiINQnJ (ORCPT + 99 others); Wed, 14 Sep 2022 12:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiINQnD (ORCPT ); Wed, 14 Sep 2022 12:43:03 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF956E8B5; Wed, 14 Sep 2022 09:43:00 -0700 (PDT) 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=drGd84Y88D87DtABnnd7yh6bhIO3nFxVGZfiNKSay/w=; b=NJ6SAfFns58rMbVH+azyEAlIBe P6n1bn9OXiF4fmUEUpqXGV/bE106qYmZbX/MwFVbHxtW6ssgk2PCE8UfNTQg1aWm+yynxcJ9j7g08 8/tgQ5onCzhF8MKSQaEQ6zA3aarCv+3D7yqjX8P1okh4bYNOq1WFHE1a4IQDf5KHdx5u5zA+Wymlc S+7i9ko/VpxQnZRAsQ62an08GtRr8DVSaNW3j49A/qLEWP1M+neWYX1OVsjvTIT7LfH477m66cmRa Nyt7CbCvmVkXs5Lmdv1xX0vhwGMMyYK/hJL+vP9XhDhzkKBGXkATkAHo1w7IXkb8b+clGQVzjQxRV f5T3UCDA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1oYVTE-00GF4L-1R; Wed, 14 Sep 2022 16:42:40 +0000 Date: Wed, 14 Sep 2022 17:42:40 +0100 From: Al Viro To: Jan Kara Cc: Christoph Hellwig , 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: <20220831041843.973026-1-jhubbard@nvidia.com> <20220831041843.973026-5-jhubbard@nvidia.com> <103fe662-3dc8-35cb-1a68-dda8af95c518@nvidia.com> <20220906102106.q23ovgyjyrsnbhkp@quack3> <20220914145233.cyeljaku4egeu4x2@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220914145233.cyeljaku4egeu4x2@quack3> Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Sep 14, 2022 at 04:52:33PM +0200, Jan Kara wrote: > > ================================================================================= > > CASE 5: Pinning in order to write to the data within the page > > ------------------------------------------------------------- > > Even though neither DMA nor Direct IO is involved, just a simple case of "pin, > > write to a page's data, unpin" can cause a problem. Case 5 may be considered a > > superset of Case 1, plus Case 2, plus anything that invokes that pattern. In > > other words, if the code is neither Case 1 nor Case 2, it may still require > > FOLL_PIN, for patterns like this: > > > > Correct (uses FOLL_PIN calls): > > pin_user_pages() > > write to the data within the pages > > unpin_user_pages() > > > > INCORRECT (uses FOLL_GET calls): > > get_user_pages() > > write to the data within the pages > > put_page() > > ================================================================================= > > Yes, that was my point. The thing is, at which point do we pin those pages? pin_user_pages() works by userland address; by the time we get to any of those we have struct page references and no idea whether they are still mapped anywhere. How would that work? What protects the area where you want to avoid running into pinned pages from previously acceptable page getting pinned? If "they must have been successfully unmapped" is a part of what you are planning, we really do have a problem...