Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2203766imu; Fri, 14 Dec 2018 07:22:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXWORAx5UEstai5l6VXETcR/3uJFueWxxiyK5bl39Ek5v3IpxjoTiLnpayZAqni4+Tu35X X-Received: by 2002:a17:902:50e3:: with SMTP id c32mr3304485plj.318.1544800956222; Fri, 14 Dec 2018 07:22:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544800956; cv=none; d=google.com; s=arc-20160816; b=mKFy/RQaND9zkndnj3rGzH79yWUuhRoACxorJAeNvXTwyRTqNd9MegY6sNGKF4t4y7 fO/WbAzF+kGHtcV00EewXsdsR9jHzsut3xvNmqXqchHJOrHIyUsB4IlC67euQziIIyE+ cBOkSEL4QMHRrycC1fuCC6VhNccFko9EhtlYP5lBknVvY0UbOh7myj+N1GO9irmq3/pC IY4IvPlsFOwGa3wzb9IKLt5Ns6fI3g0fNHzDe9tZ+4oHIEf7II4S/cvr10Nn32N3Lcqh 5XyDKMiWHPFhYSVasZvJYokk7Qyk3eXnfX3Ag9THw3eSH6VtSGkSfcIAo+OGxDMpBCZC eL3g== 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=BaFAH7R/isxLBAvhX1YmY8x00SwJbdVW+OzAqHpYA5A=; b=HojbjjzPoekCqncpP8spgUu5YVulcraPG9xzVqsfYDP3abSvdj87U2en8BhzsAewM6 27/JKlzdedRPDMxP4CyC6fZBh5X3Fkktq2g40znryVBpL2drOKbEvsNUkh6CeU5hjwfJ A+WKhuXWbcbcj8Mn1Vi+33+H9QpXjaRzEzLCoXSJyL5sWhtmY+//e9MAGbP526R5UDPB o7NeBS7AntmNdJdrnMEax8cO4CiqU5JpF4XQ/gBRMHSv85j+4OxLuvviVVYvbKDviwTH /tpcBYpSS73QZKu5byVfeKbiWKk4KCX5Cz++2mFIx0ISILRPlsKUCnWm1b7RzrrjMhw7 mlTQ== 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 f186si4289553pfb.67.2018.12.14.07.22.12; Fri, 14 Dec 2018 07:22:36 -0800 (PST) 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 S1730258AbeLNPUo (ORCPT + 99 others); Fri, 14 Dec 2018 10:20:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49894 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbeLNPUo (ORCPT ); Fri, 14 Dec 2018 10:20:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CC1B30039A5; Fri, 14 Dec 2018 15:20:43 +0000 (UTC) Received: from redhat.com (ovpn-125-82.rdu2.redhat.com [10.10.125.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C39C429ADB; Fri, 14 Dec 2018 15:20:40 +0000 (UTC) Date: Fri, 14 Dec 2018 10:20:38 -0500 From: Jerome Glisse To: John Hubbard Cc: Dan Williams , david , Jan Kara , Matthew Wilcox , John Hubbard , Andrew Morton , Linux MM , tom@talpey.com, Al Viro , benve@cisco.com, Christoph Hellwig , Christopher Lameter , "Dalessandro, Dennis" , Doug Ledford , Jason Gunthorpe , Michal Hocko , Mike Marciniszyn , rcampbell@nvidia.com, Linux Kernel Mailing List , linux-fsdevel Subject: Re: [PATCH 1/2] mm: introduce put_user_page*(), placeholder versions Message-ID: <20181214152038.GB3645@redhat.com> References: <3c4d46c0-aced-f96f-1bf3-725d02f11b60@nvidia.com> <20181208022445.GA7024@redhat.com> <20181210102846.GC29289@quack2.suse.cz> <20181212150319.GA3432@redhat.com> <20181212214641.GB29416@dastard> <20181212215931.GG5037@redhat.com> <20181213005119.GD29416@dastard> <05a68829-6e6d-b766-11b4-99e1ba4bc87b@nvidia.com> <01cf4e0c-b2d6-225a-3ee9-ef0f7e53684d@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <01cf4e0c-b2d6-225a-3ee9-ef0f7e53684d@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 14 Dec 2018 15:20:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 13, 2018 at 10:11:09PM -0800, John Hubbard wrote: > On 12/13/18 9:21 PM, Dan Williams wrote: > > On Thu, Dec 13, 2018 at 7:53 PM John Hubbard wrote: > >> > >> On 12/12/18 4:51 PM, Dave Chinner wrote: > >>> On Wed, Dec 12, 2018 at 04:59:31PM -0500, Jerome Glisse wrote: > >>>> On Thu, Dec 13, 2018 at 08:46:41AM +1100, Dave Chinner wrote: > >>>>> On Wed, Dec 12, 2018 at 10:03:20AM -0500, Jerome Glisse wrote: > >>>>>> On Mon, Dec 10, 2018 at 11:28:46AM +0100, Jan Kara wrote: > >>>>>>> On Fri 07-12-18 21:24:46, Jerome Glisse wrote: > >>>>>>> So this approach doesn't look like a win to me over using counter in struct > >>>>>>> page and I'd rather try looking into squeezing HMM public page usage of > >>>>>>> struct page so that we can fit that gup counter there as well. I know that > >>>>>>> it may be easier said than done... > >>>>>> > >> > >> Agreed. After all the discussion this week, I'm thinking that the original idea > >> of a per-struct-page counter is better. Fortunately, we can do the moral equivalent > >> of that, unless I'm overlooking something: Jerome had another proposal that he > >> described, off-list, for doing that counting, and his idea avoids the problem of > >> finding space in struct page. (And in fact, when I responded yesterday, I initially > >> thought that's where he was going with this.) > >> > >> So how about this hybrid solution: > >> > >> 1. Stay with the basic RFC approach of using a per-page counter, but actually > >> store the counter(s) in the mappings instead of the struct page. We can use > >> !PageAnon and page_mapping to look up all the mappings, stash the dma_pinned_count > >> there. So the total pinned count is scattered across mappings. Probably still need > >> a PageDmaPinned bit. > > > > How do you safely look at page->mapping from the get_user_pages_fast() > > path? You'll be racing invalidation disconnecting the page from the > > mapping. > > > > I don't have an answer for that, so maybe the page->mapping idea is dead already. > > So in that case, there is still one more way to do all of this, which is to > combine ZONE_DEVICE, HMM, and gup/dma information in a per-page struct, and get > there via basically page->private, more or less like this: The page mapcount idea does work to get a pin count. So i believe that this is what should be pursue, if no one wants to try it i will do patches. Anything else is too invasive and requires too much changes. Note that in all the discussion that happened in the mapcount having a separate pin count would not have help one bit nor would it solve the page_mkwrite issue. So we need to audit put_user_page call place and see if they can sleep and call mkwrite without issue. I believe the answer will be yes for many ... maybe all. Cheers, J?r?me