Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4159869ima; Mon, 4 Feb 2019 11:13:39 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib2rM45rVbwvXhAZMl+mx31SakLJE6YR0Jm7vpeQmodYe+o1NjEKaBDIhmW4tDRufZs6Yee X-Received: by 2002:a63:ea4f:: with SMTP id l15mr855950pgk.102.1549307619891; Mon, 04 Feb 2019 11:13:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549307619; cv=none; d=google.com; s=arc-20160816; b=JdgsxXMt7Gr+gh0Sv5F49BnesETEejh20Vs97p3JD+YsyPP2JZBe61Mffy/Xub8A0z J64Xz+W5yl7BOlbSiNK6Xa7b0cmnT65Hig7PibQFuOqh4qZJT3r+nILFWe+rX0LIRZGW 1khJEx2e2Fd0MnXud+Zp+HNFQi16o2ZYIcBgqUAkxyC0WVJaCIY1eM95z9WMk/5bUgTY bnkG9tahhJjlcrocJCR09m+b95N2fUXDXMqiUaDPHq34e7W1dV//hjURsxbnEMKPija8 yfp3nwttP2cUv3FQGnH1rXl3Pd+dN/HXs8B2440YthM8eV2FkSX83nXeqxENDWkqR90z z4bg== 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=WJmOpp9hjc5i9FcdMolKyZT9L4tb15BeDAuReza4xvo=; b=DpDX3cIUIQL0Bx7NbKhOIvSIA4IipDFNY+P+SK6GSwiHomjP0Xz77b+hjYQODPhT71 jdaAwjvPhdCmlaa+G70lWyciknk4NuztHrNoD9c1Cj93e6NCNJvlIE/h3lJgNUXKHOHn PuYUhqhisy7o1/oxSw86rxFGgWCcWV2BejxjzgAAMNYKr30WTTmVkEOn81KF1MtYMJYr kvWEoSAdA+a4veRvkQARknnwz6FMOFgxH56MIGwmcyJi84Erztf77y2FELTgdDJFGK3I 8AG2kbUsVTrk9grnMII1IPrzYPSD4yxUs1vqJ8b9Z+qkNa2j5rL873In6st6TQv4VqJe Pu0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=LzzXd638; 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 6si765008plc.241.2019.02.04.11.13.20; Mon, 04 Feb 2019 11:13:39 -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=LzzXd638; 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 S1729619AbfBDTLv (ORCPT + 99 others); Mon, 4 Feb 2019 14:11:51 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:17236 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbfBDTLu (ORCPT ); Mon, 4 Feb 2019 14:11:50 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 04 Feb 2019 11:11:18 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 04 Feb 2019 11:11:48 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 04 Feb 2019 11:11:48 -0800 Received: from [10.110.48.28] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 4 Feb 2019 19:11:48 +0000 Subject: Re: [PATCH 4/6] mm/gup: track gup-pinned pages To: Matthew Wilcox , CC: Andrew Morton , , Al Viro , Christian Benvenuti , Christoph Hellwig , Christopher Lameter , Dan Williams , Dave Chinner , Dennis Dalessandro , Doug Ledford , Jan Kara , Jason Gunthorpe , Jerome Glisse , Michal Hocko , Mike Rapoport , Mike Marciniszyn , Ralph Campbell , Tom Talpey , LKML , References: <20190204052135.25784-1-jhubbard@nvidia.com> <20190204052135.25784-5-jhubbard@nvidia.com> <20190204181944.GD21860@bombadil.infradead.org> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Mon, 4 Feb 2019 11:11:47 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190204181944.GD21860@bombadil.infradead.org> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL106.nvidia.com (172.18.146.12) 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=1549307478; bh=WJmOpp9hjc5i9FcdMolKyZT9L4tb15BeDAuReza4xvo=; 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=LzzXd638u1XMmc+ElbDj1YOanoDeGKHAdwbB4+O7StuXZJE3+DtthQyzUge3Cy/1i NTwlka1kfeKHNp722TaLkL/+Zgw+xv4LTc1MEZy90zZwbUHCQQRCWTRQdd47B+kRRO lixXxP5Wo4PIIgxfTIb7aDkNOrSAIUCmugEwjvnIpbGj9tNOgA1v+SBBLIS16L7cQB hI+V0E/XispNBrQ5DPaccPToIUpaekPPsStWy0a1WH63K6wSNw9v3wyeuxgPNOcRGH 6BNWkB3sZlziejAvgJoColb5Lg2au/n3e6AGqaormGN0LtHtVP+sSlp5YstQoL51+q HqSFul0QqR9mg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/4/19 10:19 AM, Matthew Wilcox wrote: > On Sun, Feb 03, 2019 at 09:21:33PM -0800, john.hubbard@gmail.com wrote: >> +/* >> + * GUP_PIN_COUNTING_BIAS, and the associated functions that use it, overload >> + * the page's refcount so that two separate items are tracked: the original page >> + * reference count, and also a new count of how many get_user_pages() calls were >> + * made against the page. ("gup-pinned" is another term for the latter). >> + * >> + * With this scheme, get_user_pages() becomes special: such pages are marked >> + * as distinct from normal pages. As such, the new put_user_page() call (and >> + * its variants) must be used in order to release gup-pinned pages. >> + * >> + * Choice of value: >> + * >> + * By making GUP_PIN_COUNTING_BIAS a power of two, debugging of page reference >> + * counts with respect to get_user_pages() and put_user_page() becomes simpler, >> + * due to the fact that adding an even power of two to the page refcount has >> + * the effect of using only the upper N bits, for the code that counts up using >> + * the bias value. This means that the lower bits are left for the exclusive >> + * use of the original code that increments and decrements by one (or at least, >> + * by much smaller values than the bias value). >> + * >> + * Of course, once the lower bits overflow into the upper bits (and this is >> + * OK, because subtraction recovers the original values), then visual inspection >> + * no longer suffices to directly view the separate counts. However, for normal >> + * applications that don't have huge page reference counts, this won't be an >> + * issue. >> + * >> + * This has to work on 32-bit as well as 64-bit systems. In the more constrained >> + * 32-bit systems, the 10 bit value of the bias value leaves 22 bits for the >> + * upper bits. Therefore, only about 4M calls to get_user_page() may occur for >> + * a page. > > The refcount is 32-bit on both 64 and 32 bit systems. This limit > exists on both sizes of system. > Oh right, I'll just delete that last paragraph, then. Thanks for catching that. thanks, -- John Hubbard NVIDIA