Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8769707imu; Tue, 4 Dec 2018 13:57:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/XplaJTJBBF+LXy6JSpBIi4m7iYquFneVfc8p/Hx35q6zdekRPBOgRQ6NAMHT5YU5EPANJ/ X-Received: by 2002:a63:680a:: with SMTP id d10mr18371709pgc.396.1543960656503; Tue, 04 Dec 2018 13:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543960656; cv=none; d=google.com; s=arc-20160816; b=MH9UAAFNETbXUWg9eiBAOYscKuu4tpzXRosLh5e/GM4bLy5XLd8tv1SlRj9NXN2XsG GjEZMNRwmourGltn/zmo3GgIGI9YFqMg2RMyQPdSUXX8LPnRdoWyZdB245tuzoJPQUKy Kksoy/NUyW+vaXhsknOntd0MiAHhUAEf7l7+gDJ8rYx6DYjmhTIjOczLZYJEGg8zABPh UdnHv7y3c6O94WZC6uev/MPdnjKUmaAU+nsXAUQcojuxSmk8oRZzZS3U4xEOpWR5ECso dkyt8YFXn0veEdCVjoPJ0SkEDJGLyZcBjVhBO+XPg61LcwJw1hQ7U9HtmNDW2SWhNYMT cq/A== 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=7W2wfTpgdToO6GpOI/NSe9+5+c9YZgpSZTI6IpFX1Vo=; b=TpfDiTwMI2sq5UmKw7f13NtnT64UKFlGXElOY7wQo1+UApG1vpSeQa0rrJn+lC/+ox v8FSaP7dkZ47s1gx7cuQJ9rF/7FxM+wC+Od60gi1hjQTdEbgESqJ6MahXB544n/7i0MU iTzjBpkE8SjssJ5iqkaCZbV+zIYEYn4wTTV+ZyU2Xo+8FdkExbbrOq1K1Zxgu2eugx81 RUw/uHWtkz1xTsMw2ODP0TvRMo8diYeZdo2xSL3xOlv0RxIPl8DcUrRxsH6lFLiVSx8Y rL3gCbUaOizawPiNhWPfCBIByDML0jNUaOk28PTvZvdbClfuMHXpfb7NVW7kuOKI6Wzt Wn9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=YbBuOH9e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si16828360pgf.453.2018.12.04.13.57.20; Tue, 04 Dec 2018 13:57: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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=YbBuOH9e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbeLDV4j (ORCPT + 99 others); Tue, 4 Dec 2018 16:56:39 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:18830 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbeLDV4j (ORCPT ); Tue, 4 Dec 2018 16:56:39 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 04 Dec 2018 13:56:38 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 04 Dec 2018 13:56:37 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 04 Dec 2018 13:56:37 -0800 Received: from [10.110.48.28] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 4 Dec 2018 21:56:36 +0000 Subject: Re: [PATCH 1/2] mm: introduce put_user_page*(), placeholder versions To: Dan Williams , John Hubbard CC: Andrew Morton , Linux MM , Jan Kara , , Al Viro , , Christoph Hellwig , Christopher Lameter , "Dalessandro, Dennis" , Doug Ledford , Jason Gunthorpe , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Matthew Wilcox , Michal Hocko , , , Linux Kernel Mailing List , linux-fsdevel References: <20181204001720.26138-1-jhubbard@nvidia.com> <20181204001720.26138-2-jhubbard@nvidia.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Tue, 4 Dec 2018 13:56:36 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US-large Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1543960598; bh=7W2wfTpgdToO6GpOI/NSe9+5+c9YZgpSZTI6IpFX1Vo=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=YbBuOH9eie1gri8DKOFeUC4jDGkI5KLAADnmkOQo2/34Vgcoa+Oev4ouHVTeFTNma Vyt628PcOHN5bE8bixBfJCNM75XeI20SbOEOVn1Kq6RTN3+ildVPrETzLzpk5G+PkO fveqdO3dXySQnD9R74UdtRS2LDFU2/OqVTgzPmyi8YT3PUrv5mlNdCY73Q86Gwt4wA GzFCt5+oc9PIyIVtkDAx0ldmFOgHXe8ZubOE4SiAz1743eLXOEMMh9jSrteWFBkQNM RLFaDPFFGi86oBpJH74O6YxWZQgys58aHpA2CUj59wV2u2VVJ4AHY+pGi4TINyqX6G QEkrGNicjHVtw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/4/18 12:28 PM, Dan Williams wrote: > On Mon, Dec 3, 2018 at 4:17 PM wrote: >> >> From: John Hubbard >> >> Introduces put_user_page(), which simply calls put_page(). >> This provides a way to update all get_user_pages*() callers, >> so that they call put_user_page(), instead of put_page(). >> >> Also introduces put_user_pages(), and a few dirty/locked variations, >> as a replacement for release_pages(), and also as a replacement >> for open-coded loops that release multiple pages. >> These may be used for subsequent performance improvements, >> via batching of pages to be released. >> >> This is the first step of fixing the problem described in [1]. The steps >> are: >> >> 1) (This patch): provide put_user_page*() routines, intended to be used >> for releasing pages that were pinned via get_user_pages*(). >> >> 2) Convert all of the call sites for get_user_pages*(), to >> invoke put_user_page*(), instead of put_page(). This involves dozens of >> call sites, and will take some time. >> >> 3) After (2) is complete, use get_user_pages*() and put_user_page*() to >> implement tracking of these pages. This tracking will be separate from >> the existing struct page refcounting. >> >> 4) Use the tracking and identification of these pages, to implement >> special handling (especially in writeback paths) when the pages are >> backed by a filesystem. Again, [1] provides details as to why that is >> desirable. > > I thought at Plumbers we talked about using a page bit to tag pages > that have had their reference count elevated by get_user_pages()? That > way there is no need to distinguish put_page() from put_user_page() it > just happens internally to put_page(). At the conference Matthew was > offering to free up a page bit for this purpose. > ...but then, upon further discussion in that same session, we realized that that doesn't help. You need a reference count. Otherwise a random put_page could affect your dma-pinned pages, etc, etc. I was not able to actually find any place where a single additional page bit would help our situation, which is why this still uses LRU fields for both the two bits required (the RFC [1] still applies), and the dma_pinned_count. [1] https://lore.kernel.org/r/20181110085041.10071-7-jhubbard@nvidia.com >> [1] https://lwn.net/Articles/753027/ : "The Trouble with get_user_pages()" >> >> Reviewed-by: Jan Kara > > Wish, you could have been there Jan. I'm missing why it's safe to > assume that a single put_user_page() is paired with a get_user_page()? > A put_user_page() per page, or a put_user_pages() for an array of pages. See patch 0002 for several examples. thanks, -- John Hubbard NVIDIA