Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1099121ybl; Fri, 16 Aug 2019 08:53:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhOLHSo6k/wTq1A9FUlit8HTdTSOF8nCo77ozQfCWPTeGZZqh8ZoptNTI6tprnhvbLT5IZ X-Received: by 2002:a17:90a:17aa:: with SMTP id q39mr7892330pja.106.1565970815708; Fri, 16 Aug 2019 08:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565970815; cv=none; d=google.com; s=arc-20160816; b=1CvRZV3kt1cFI0QHJYmIxYVFnlixfAYFQd4YgSguivZR/LAnJg6ztn+yAyi6XgPCyH OTl57sfW0wmlDZob2v2LH9EXwDA/nGf6CjnVGfB+VdJc5ovNX2F1XztO2757tKMaCXbi xTiNEFFpERyGPeaosCvdv4gSGcck/Jw7uIRvXBv9Bfb5pWXJtAa/vzMSJjb4sNyuU9mr T2/kxP8oiN9uxBAc/+Q0iD/0K+t99copYgZh3WmYJpVamdqbAZRfphjc54o3NRVeRioF HyiUErFJOHEDuO2PXVtAXtO3gZ2bkbWggL6zSE9yoc5ht/v0mGaY4Bt9jhMQ9bb4LFGa YNvQ== 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=qtOOVRFpIrBnOewLylirTwYaIZYE39hkAnYKBI/S6kY=; b=dNNX+RZ5CL5/RFxEeYiMYh0gnPR/wIRPR0xn8GzKpbwz6KeNP952wLgg8UD9W9pM3b HDhcr/lcScMKW0fjj+Iegl6wQGk1jRFs+8SRBl1KgGoM5xvbdg0AX0f5zD2rv7p6Hg8h fW6qVP+mMnzK22V24Lvd+iw+PNRrGJHsRezO1CgL/Iux2NQENA7Lp0VIwYq7jzFmLz7X aAVCjxzUC5a+RfXVOTEU4+k8aZDRRl+WeB2jOGER44jhdFta55VZLRnawSxUpds+OTcX ZkuhSE0LWh8NNDzBVcmkJVv/ipbt4QgikRWKcgInnZYYtKG9FRlGToQDsvz/JzPd3av8 yotQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c25si4100324pgm.73.2019.08.16.08.53.20; Fri, 16 Aug 2019 08:53:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbfHPPwY (ORCPT + 99 others); Fri, 16 Aug 2019 11:52:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55014 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbfHPPwY (ORCPT ); Fri, 16 Aug 2019 11:52:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 222B486663; Fri, 16 Aug 2019 15:52:24 +0000 (UTC) Received: from redhat.com (ovpn-123-168.rdu2.redhat.com [10.10.123.168]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6BF4583E86; Fri, 16 Aug 2019 15:52:22 +0000 (UTC) Date: Fri, 16 Aug 2019 11:52:20 -0400 From: Jerome Glisse To: Jan Kara Cc: Vlastimil Babka , John Hubbard , Ira Weiny , Andrew Morton , Christoph Hellwig , Dan Williams , Dave Chinner , Jason Gunthorpe , LKML , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [RFC PATCH 2/2] mm/gup: introduce vaddr_pin_pages_remote() Message-ID: <20190816155220.GC3149@redhat.com> References: <20190813210857.GB12695@iweiny-DESK2.sc.intel.com> <90e5cd11-fb34-6913-351b-a5cc6e24d85d@nvidia.com> <20190814234959.GA463@iweiny-DESK2.sc.intel.com> <2cbdf599-2226-99ae-b4d5-8909a0a1eadf@nvidia.com> <20190815132622.GG14313@quack2.suse.cz> <20190815133510.GA21302@quack2.suse.cz> <0d6797d8-1e04-1ebe-80a7-3d6895fe71b0@suse.cz> <20190816154404.GF3041@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190816154404.GF3041@quack2.suse.cz> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 16 Aug 2019 15:52:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 16, 2019 at 05:44:04PM +0200, Jan Kara wrote: > On Fri 16-08-19 10:47:21, Vlastimil Babka wrote: > > On 8/15/19 3:35 PM, Jan Kara wrote: > > >> > > >> So when the GUP user uses MMU notifiers to stop writing to pages whenever > > >> they are writeprotected with page_mkclean(), they don't really need page > > >> pin - their access is then fully equivalent to any other mmap userspace > > >> access and filesystem knows how to deal with those. I forgot out this case > > >> when I wrote the above sentence. > > >> > > >> So to sum up there are three cases: > > >> 1) DIO case - GUP references to pages serving as DIO buffers are needed for > > >> relatively short time, no special synchronization with page_mkclean() or > > >> munmap() => needs FOLL_PIN > > >> 2) RDMA case - GUP references to pages serving as DMA buffers needed for a > > >> long time, no special synchronization with page_mkclean() or munmap() > > >> => needs FOLL_PIN | FOLL_LONGTERM > > >> This case has also a special case when the pages are actually DAX. Then > > >> the caller additionally needs file lease and additional file_pin > > >> structure is used for tracking this usage. > > >> 3) ODP case - GUP references to pages serving as DMA buffers, MMU notifiers > > >> used to synchronize with page_mkclean() and munmap() => normal page > > >> references are fine. > > > > IMHO the munlock lesson told us about another one, that's in the end equivalent > > to 3) > > > > 4) pinning for struct page manipulation only => normal page references > > are fine > > Right, it's good to have this for clarity. > > > > I want to add that I'd like to convert users in cases 1) and 2) from using > > > GUP to using differently named function. Users in case 3) can stay as they > > > are for now although ultimately I'd like to denote such use cases in a > > > special way as well... > > > > So after 1/2/3 is renamed/specially denoted, only 4) keeps the current > > interface? > > Well, munlock() code doesn't even use GUP, just follow_page(). I'd wait to > see what's left after handling cases 1), 2), and 3) to decide about the > interface for the remainder. > For 3 we do not need to take a reference at all :) So just forget about 3 it does not exist. For 3 the reference is the reference the CPU page table has on the page and that's it. GUP is no longer involve in ODP or anything like that. Cheers, J?r?me