Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp709097ybg; Fri, 12 Jun 2020 12:26:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZzxH6bPu5b0wQwIxsO2W8ns89LcLQLs7sA+dT4pG3jxgMQPcdUTcBPy68fO+p2x8png9s X-Received: by 2002:a17:906:3951:: with SMTP id g17mr15214368eje.414.1591990004368; Fri, 12 Jun 2020 12:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591990004; cv=none; d=google.com; s=arc-20160816; b=olkndlgFa4IBunBklpth9DU8joxa5ggR57BN7ctsymtxee95eRk7znDz8lCQFATub8 n3sw10p04D6ppo4PYeXrVqpwbnNvjHsc/Ia5RoBbtBm6wwf6xOZB8cCp8T7G6mIQSL0U 5iZQuDgT+toreGEImcinDX6XsyiZZ4yfPFsGrPNJ35kxGlVScSZSe2mTnBcJC+SwhxPI tgRZZBReuqhc7rihqJ8gUNzdY/Nz1Ukz2UOh65slt0sAZFgrHtyMr7qutbEhm780h0Kc FcWThwTbILJ0cBaIqrW463J/z4raNc8I0MgrG8dGGSdh9StPG5Xfazad/pfsw7oo4bw/ U92Q== 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=XNIkzHywKoH/b5FoSCgmMlwYaQtQXQo8Xsv8G4L19+I=; b=OvkUhFx3R/ryTBnykHv3eLOxcyyZY+VtY7F4pIIOI55QT+Eh3h7lvVfymQs6vOAMLA L3W1WKhDHH9a78ugFCQ2q9/kMouBVyZf4FWjgWXszvO9kV6Id2yBI7drQGE1MwAvyvfR tUhLtQBd+EJbIw/IAVSdRS6Gbnzq71NgBQl7ynUo3I5yurGk+Rui+9D8giVyTSKZ/phg QBN3TRWg5VjqoTxKFFVOYB2hEgY4xzNWEks2s3ZryghMS1f9dJ8iwXrJnHJWaDXbPCT+ aPjIajtWJ4W3YYk9sgmqpLjxOR0bscwnhQ8vMTFA0d37gLsKbEDWhaGYq1LJ7SeJan+t 2QuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JWOkDkyk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t25si4099777edq.407.2020.06.12.12.26.22; Fri, 12 Jun 2020 12:26:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JWOkDkyk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgFLTYc (ORCPT + 99 others); Fri, 12 Jun 2020 15:24:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbgFLTYc (ORCPT ); Fri, 12 Jun 2020 15:24:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11CE8C03E96F; Fri, 12 Jun 2020 12:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; 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=XNIkzHywKoH/b5FoSCgmMlwYaQtQXQo8Xsv8G4L19+I=; b=JWOkDkykP2kWcImMSx7orhKPGu HQqxsoObXbcgFBrMCclC291CBzUDZx+2r9YIPj5QmzHGlljusdNWhWkt6AC8D25b5ACpf9qxNGPMF f63BTFa3uWqJy4FaDGSz4Xh7rhJ4r9uMrqhzkGE4orGEFDDXzGymYhPSnJtz5/lqSNqF3bEFleH8F iZIIcvEQlPD6tS8dtKPW88CcpSZ5YBV3xOYh88RSIxEzL+FbipCq/pC+XntBHNCTHzsTXGM9zEmWU EZgqeVnfWg6mVgRLnanPIeMXv4T1rolzFIX4uMCeBAwTlkYXQvqQTjLYt+DHwJnFjLV3cRYpXlcq2 w2uGuFGA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jjpHu-0007JA-Bk; Fri, 12 Jun 2020 19:24:26 +0000 Date: Fri, 12 Jun 2020 12:24:26 -0700 From: Matthew Wilcox To: John Hubbard Cc: Andrew Morton , "Michael S . Tsirkin" , Jason Wang , Vlastimil Babka , =?iso-8859-1?B?Suly9G1l?= Glisse , Jan Kara , Dave Chinner , Souptick Joarder , Jonathan Corbet , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, LKML , linux-mm@kvack.org Subject: Re: [PATCH 1/2] docs: mm/gup: pin_user_pages.rst: add a "case 5" Message-ID: <20200612192426.GK8681@bombadil.infradead.org> References: <20200529234309.484480-1-jhubbard@nvidia.com> <20200529234309.484480-2-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200529234309.484480-2-jhubbard@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 29, 2020 at 04:43:08PM -0700, John Hubbard 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, > +access 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() > + access the data within the pages > + set_page_dirty_lock() > + unpin_user_pages() > + > +INCORRECT (uses FOLL_GET calls): > + get_user_pages() > + access the data within the pages > + set_page_dirty_lock() > + put_page() Why does this case need to pin? Why can't it just do ... get_user_pages() lock_page(page); ... modify the data ... set_page_dirty(page); unlock_page(page);