Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3464571imu; Mon, 10 Dec 2018 02:39:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/U/4WdARnD0UWa2frzn5ZAkQufVbnWqu7R90Jt5P59S4ZjIk+024KBCFI8JLkolWj9CT7qc X-Received: by 2002:a17:902:780c:: with SMTP id p12mr11386472pll.197.1544438388473; Mon, 10 Dec 2018 02:39:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544438388; cv=none; d=google.com; s=arc-20160816; b=Gg8aJNfMWuvNmG5TjKPDE3blyTSwpZvgqxfJU6RYYP2OQlS7fagR27zPyLUbtTIFze 9Vkds2fwFAgYT2+8lwDOUjB7fmI14XugARhEyvO2NskcarHoRlUpogEDdhONJlRRKiIu +OFE+gJ7Ehuwoo9JnLfP6olmkttO1HqXUD76GQ87HpBqP3PWR1V8pVD0hJOJkCp0p0jJ xP0H6jUZUQh8dcTOyB11qJahajoKPhoOacGgzfZiii0wfOvIae7rKyljV3brzocjIYtZ cTq7lhNDhp9JLMSzocUd5RCCemFzQpKmmc/e+JLpprdkWMz1Ebw2/5E6PCcTh4osH6vT n84g== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=l/LHs8rXloJB2ZPlH0z5dIg6FFA2apEpFE/h+5vV/0E=; b=n4No9ENENj+4b2deO8oSVS5p9AOvGiQ2B3dtUkkcpVZuNZYWQ06dpJ3B1t3Sa2VHaa fTi9CMVS9z1oDklkjnW0HVnaRZblbNhkftA3SwxvZ/JMk3f8A+JkggVoUR31UojuiGuB PxN/Nxz0KS/mJnJI+eu4CUIFXR0SMv9jJlib3iy6ycY23K6HHBxsHMEBb4nW5SpRiEjV Nrvddjem39lddHLp/L0LlCh1OA81P+sHgKLUqwIZzcC76LklUjBwoK3tcPjacQ5HdIR0 P2qg9KEtxp/Ichr3d79ziwaAm6i8/dROGV9dAC6MW/eHmtC4CJC2JhrLqOH1mUrzjj6d W2Yg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si9431830pgk.217.2018.12.10.02.39.33; Mon, 10 Dec 2018 02:39:48 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727243AbeLJK2x (ORCPT + 99 others); Mon, 10 Dec 2018 05:28:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:50358 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726146AbeLJK2w (ORCPT ); Mon, 10 Dec 2018 05:28:52 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D6549AE10; Mon, 10 Dec 2018 10:28:49 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id DA8D51E13F8; Mon, 10 Dec 2018 11:28:46 +0100 (CET) Date: Mon, 10 Dec 2018 11:28:46 +0100 From: Jan Kara To: Jerome Glisse Cc: John Hubbard , Matthew Wilcox , Dan Williams , John Hubbard , Andrew Morton , Linux MM , Jan Kara , tom@talpey.com, Al Viro , benve@cisco.com, Christoph Hellwig , Christopher Lameter , "Dalessandro, Dennis" , Doug Ledford , Jason Gunthorpe , Michal Hocko , mike.marciniszyn@intel.com, rcampbell@nvidia.com, Linux Kernel Mailing List , linux-fsdevel Subject: Re: [PATCH 1/2] mm: introduce put_user_page*(), placeholder versions Message-ID: <20181210102846.GC29289@quack2.suse.cz> References: <3c91d335-921c-4704-d159-2975ff3a5f20@nvidia.com> <20181205011519.GV10377@bombadil.infradead.org> <20181205014441.GA3045@redhat.com> <59ca5c4b-fd5b-1fc6-f891-c7986d91908e@nvidia.com> <7b4733be-13d3-c790-ff1b-ac51b505e9a6@nvidia.com> <20181207191620.GD3293@redhat.com> <3c4d46c0-aced-f96f-1bf3-725d02f11b60@nvidia.com> <20181208022445.GA7024@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181208022445.GA7024@redhat.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 Fri 07-12-18 21:24:46, Jerome Glisse wrote: > Another crazy idea, why not treating GUP as another mapping of the page > and caller of GUP would have to provide either a fake anon_vma struct or > a fake vma struct (or both for PRIVATE mapping of a file where you can > have a mix of both private and file page thus only if it is a read only > GUP) that would get added to the list of existing mapping. > > So the flow would be: > somefunction_thatuse_gup() > { > ... > GUP(_fast)(vma, ..., fake_anon, fake_vma); > ... > } > > GUP(vma, ..., fake_anon, fake_vma) > { > if (vma->flags == ANON) { > // Add the fake anon vma to the anon vma chain as a child > // of current vma > } else { > // Add the fake vma to the mapping tree > } > > // The existing GUP except that now it inc mapcount and not > // refcount > GUP_old(..., &nanonymous, &nfiles); > > atomic_add(&fake_anon->refcount, nanonymous); > atomic_add(&fake_vma->refcount, nfiles); > > return nanonymous + nfiles; > } Thanks for your idea! This is actually something like I was suggesting back at LSF/MM in Deer Valley. There were two downsides to this I remember people pointing out: 1) This cannot really work with __get_user_pages_fast(). You're not allowed to get necessary locks to insert new entry into the VMA tree in that context. So essentially we'd loose get_user_pages_fast() functionality. 2) The overhead e.g. for direct IO may be noticeable. You need to allocate the fake tracking VMA, get VMA interval tree lock, insert into the tree. Then on IO completion you need to queue work to unpin the pages again as you cannot remove the fake VMA directly from interrupt context where the IO is completed. You are right that the cost could be amortized if gup() is called for multiple consecutive pages however for small IOs there's no help... 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... Honza -- Jan Kara SUSE Labs, CR