Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp403421ybg; Mon, 1 Jun 2020 04:36:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygZbyRKiIhLrZDoa2C6MoachGr0+lM+2jonPZGSaenrUgIMc4yOtjFCvGQUyyZoliyemPs X-Received: by 2002:a17:907:1005:: with SMTP id ox5mr18374905ejb.480.1591011400409; Mon, 01 Jun 2020 04:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591011400; cv=none; d=google.com; s=arc-20160816; b=eDq3niTsPCexkhst2K1KWP78R7lgVcjXWOeSze+1SORipRKeYaHADGfnHDt051w1oQ sxQgdgB6hL3aSQhT4fPpK6GaI1TJCqKyEgn0e7HsJIcjjCZcjs5VG8OdKCEmy+xElMYQ Amp6t3nsyhvw3lMcJ0S6sbDXCe+G0LGagdzcEC0s0ixV8RTzmpiECyW8XrkYWAs1UYrj ihPCfrgBmY+Z7yBvQboiXKa/LdhrO9SBY1XJg0LD2c0q3M7nVYz04AvCuFBVnuF0Sd5s 5Fq1kDFe2gLTX3Wf+592AOeLkwUC44WZfU+vuwXINPf2TQudr6SSjza7qLHsNLqujJtd 0wOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=On8dSOEKZ4SjVDg8CUuqbE4HXhL2Jwcnsl2seY3VnMI=; b=ZAM8orhUqgkDhcZCssdpPjUk7dNOmoU9MLtYnJI2+nL8yOh4JbQQzmME/3CbJ1buoP flFjZa3wnAePIMr9i5wRDOH6BeMpDTOUxwtA9F7/KwKVyzUVadOQRen//3TRY7WcShuF v83pnWe8zarz0Y4aL3a6DWXxcss3ijN5wuzipJMT1+W8H69JcRN2kY2BYLfMH8LV3v2x /LWlkaUg+rOA51Nqcm7e+Cgmzt8SqBwrbX5B9IFOcCQwPKnUiUqdvPd1rJdfwl0NfQFx oy8XFG+pB8WgN2j66wkgtna/mIAx3AsAIrA+IgoqNlLxk9lphM356Zle8+H2ePFyvOHH Q1tA== ARC-Authentication-Results: i=1; mx.google.com; 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 u1si11605074edb.96.2020.06.01.04.36.17; Mon, 01 Jun 2020 04:36:40 -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; 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 S1726901AbgFALe1 (ORCPT + 99 others); Mon, 1 Jun 2020 07:34:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:56316 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgFALe0 (ORCPT ); Mon, 1 Jun 2020 07:34:26 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 54BD1AECB; Mon, 1 Jun 2020 11:34:26 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 1217B1E0948; Mon, 1 Jun 2020 13:34:24 +0200 (CEST) Date: Mon, 1 Jun 2020 13:34:24 +0200 From: Jan Kara 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 v2 1/2] docs: mm/gup: pin_user_pages.rst: add a "case 5" Message-ID: <20200601113424.GF3960@quack2.suse.cz> References: <20200601052633.853874-1-jhubbard@nvidia.com> <20200601052633.853874-2-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200601052633.853874-2-jhubbard@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 31-05-20 22:26:32, John Hubbard wrote: > There are four cases listed in pin_user_pages.rst. These are > intended to help developers figure out whether to use > get_user_pages*(), or pin_user_pages*(). However, the four cases > do not cover all the situations. For example, drivers/vhost/vhost.c > has a "pin, write to page, set page dirty, unpin" case. > > Add a fifth case, to help explain that there is a general pattern > that requires pin_user_pages*() API calls. > > Cc: Vlastimil Babka > Cc: Jan Kara > Cc: J?r?me Glisse > Cc: Dave Chinner > Cc: Jonathan Corbet > Cc: linux-doc@vger.kernel.org > Cc: linux-fsdevel@vger.kernel.org > Signed-off-by: John Hubbard Looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > Documentation/core-api/pin_user_pages.rst | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/Documentation/core-api/pin_user_pages.rst b/Documentation/core-api/pin_user_pages.rst > index 4675b04e8829..6068266dd303 100644 > --- a/Documentation/core-api/pin_user_pages.rst > +++ b/Documentation/core-api/pin_user_pages.rst > @@ -171,6 +171,24 @@ If only struct page data (as opposed to the actual memory contents that a page > is tracking) is affected, then normal GUP calls are sufficient, and neither flag > needs to be set. > > +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() > + > page_maybe_dma_pinned(): the whole point of pinning > =================================================== > > -- > 2.26.2 > -- Jan Kara SUSE Labs, CR