Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp730626ybg; Fri, 12 Jun 2020 13:05:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEcNbELBfSXeJ4TG964EzV8jlCPis4/FT7dWtTIjx2hv4qKaQ9h7AbnbTiC2tzdUGHTK4F X-Received: by 2002:a05:6402:30ae:: with SMTP id df14mr12941986edb.310.1591992328995; Fri, 12 Jun 2020 13:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591992328; cv=none; d=google.com; s=arc-20160816; b=efFF1126feWEhaCEpuzVbk9A+uG7GtBRJX9ku72jJXXI21+Z05ypLryyngBCNwL0Db TNGICqtZpHZdehrE9n8paxwurbkhidKKq+MgPWDDcS3PZDmLVOmUrBuAv0s/oQvfYnPx 4lct2E3rXV0cdaHSraQYEr/9H/SIeoiM3oQ4DhaMWxhW3gNGtycY8B+dNU8mMwRHDcFU rG1Q6l4rNAFEBc/kbBtr4I8hM2M2Zs9g3eBKNbKIUhvwnqX9wn43FynZX0PFm0nM8aRh eaFI043gCT5uGczXVoIguA3hESRACXGtwjVifYkxaJHdWpcYq5AIFZI6xCCMITOJJmyy sZgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=fN6zAnkb8dRIBQrks+Oz4+vRiYcHSYaYUuw0BewGGEk=; b=WbPenHMwxV5XbKgd3CwfyL/0ocqHlBOsa6SQaSdBOBY0UW24yhZI9ZGFz16EtC7IIH vUTOVKjdmAQbQeu0RkiEQjEA+IVO20WZuUDZhi+LpwQDFEBj1c/6glTs6mBlVaL62bGK gp/Ellf62l4oNTFwfo45tZJZiOacGehNHklq5VauPs+ABaJEO8c+jBiXtUZkqzsLYW44 lDVPMhqHOAN/0W1m3WzngWa3PDSW5qSqvxtq3QD0yv0C6Q1eYIZ9cPi9RdUSnUwSnSfL ZTlYfVPeWsYf+7SgiKg4OVt6v2M670tcEZSU2HNLFJTfDlYs85ZwG+H70IP9v2MshKDh 4CTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="Mrwrs2/W"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc20si4763358edb.108.2020.06.12.13.05.06; Fri, 12 Jun 2020 13:05:28 -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=pass header.i=@nvidia.com header.s=n1 header.b="Mrwrs2/W"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbgFLUDL (ORCPT + 99 others); Fri, 12 Jun 2020 16:03:11 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:14320 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgFLUDH (ORCPT ); Fri, 12 Jun 2020 16:03:07 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 12 Jun 2020 13:02:21 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 12 Jun 2020 13:03:07 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 12 Jun 2020 13:03:07 -0700 Received: from [10.2.62.89] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 12 Jun 2020 20:03:07 +0000 Subject: Re: [PATCH 1/2] docs: mm/gup: pin_user_pages.rst: add a "case 5" To: Matthew Wilcox CC: Andrew Morton , "Michael S . Tsirkin" , Jason Wang , Vlastimil Babka , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Dave Chinner , Souptick Joarder , Jonathan Corbet , , , , , , LKML , References: <20200529234309.484480-1-jhubbard@nvidia.com> <20200529234309.484480-2-jhubbard@nvidia.com> <20200612192426.GK8681@bombadil.infradead.org> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Fri, 12 Jun 2020 13:03:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200612192426.GK8681@bombadil.infradead.org> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1591992141; bh=fN6zAnkb8dRIBQrks+Oz4+vRiYcHSYaYUuw0BewGGEk=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=Mrwrs2/WN8fnEejZcAvFi1E+ICWIQc+5sT7wEIyruy1+L8O2vF2rU8etd+2m3Rcye /0MGen72j1T2YMz8qzXatSCP76QXdLxycn/9MxrzFz+r0k+oGKr5wqPp43sFbsvvxJ kG6DIrwJ31WVrfLqK6RrOt/FtCmOVWN8cByBMW2OYkwN5lYUueiqAzGuWU0cmQv94Q Uvvv505bPXRH5YPkRvyIKX1owhLczul7/YDNdthyhbC86t0EtjEp8X1e75YFPqEGn9 iBucQvKo4smd+Vzmm9MOxV5oQ6ufLiUCUz2qRrkZ0AZiZ94MfBBuULhA48FkMlAfRC xpX4UyB4FOplg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-12 12:24, Matthew Wilcox wrote: > 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); > Yes, it could do that. And that would also make a good additional "correct" example. Especially for the case of just dealing with a single page, lock_page() has the benefit of completely fixing the problem *today*, without waiting for the pin_user_pages*() handling improvements to get implemented. And it's also another (probably better) way to fix the vhost.c problem, than commit 690623e1b496 ("vhost: convert get_user_pages() --> pin_user_pages()"). I'm inclined to leave vhost.c alone for now, unless someone really prefers it to be changed, but to update the Case 5 documentation with your point above. Sound about right? thanks, -- John Hubbard NVIDIA