Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4109033ima; Mon, 4 Feb 2019 10:20:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IYoDbDyBc5W8K2WgVJGGT2+RvBl1p0G12nZe6MH8c2yRXC8bgCEWG1selAM5pXHm6W5U+ig X-Received: by 2002:a63:5d20:: with SMTP id r32mr603303pgb.329.1549304437824; Mon, 04 Feb 2019 10:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549304437; cv=none; d=google.com; s=arc-20160816; b=zNqdvDhSToSqcA8X5kdR7WQzqNxYFypEY9a3v0HSYKwIi5iiV1nKpCCYCC0GuZq+OP NWlocva5iHWA8Gf7AmIKI1EHFVyyzUKmmojxT/fW69FVOrPzwMRFvndJ/CJ9Kiz9FqHr PUDxZL6lahIX/mcWuuv5cx/6iMDSLsmd4ydCo0U6nQwQqBFjG1gfKRxV3GC4RxMAMDES +qiBnCqpSsfp/Avdgj9wFvchmKFuyz9bxPYg+5V9G7twlWhQfR1p1xYpiHuIX181gK1J TlXydepEx/sB5qPCP0IspH6owBDaMaqvwAeUjP6pjBHFsrYclhsSp5UwXKT9Uv/4ClXv ryRg== 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:dkim-signature; bh=NG9nYwCAVqEpP+paq6QtboUvwEo6x8RZXfTYGpZRrLw=; b=Ja4no+JwW/W7GZYXx8kB8L24E/1JMiZqeMYEI7m8ChRzpg8jpUmqwVNtN37yCLKrZ/ 06t36icG2A5v843/X7KF1RUO8DeaXp4mvZ/5iYlZiJynLLgCffWFUiWk9kqXz9PTyE1L yLIiqHr6ekTwSJRXNnrev8ej7Rh4htrcbU2wAUhmVfd2Kc33uKvaTaWeCfcM3pWbCQAx aeJ/htnPw0wLqU5BRiA9UhKF1Kj9lENeLBbhyyuT13SZgdCoUHhvM0wv5qwjl7gdhytj 0rnKJF60ZawSN+6H/kW3OAikECRWgdfuFOFYS7X2ZzMUFv48mBZWXLn+1vpmr0pDBAvm D0fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uSWLen75; 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 a28si637044pgl.530.2019.02.04.10.20.20; Mon, 04 Feb 2019 10:20:37 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uSWLen75; 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 S1729262AbfBDST6 (ORCPT + 99 others); Mon, 4 Feb 2019 13:19:58 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:51512 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729127AbfBDST5 (ORCPT ); Mon, 4 Feb 2019 13:19:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NG9nYwCAVqEpP+paq6QtboUvwEo6x8RZXfTYGpZRrLw=; b=uSWLen75JY5fHulYjRaAYf7ZF orEmz+rVxtEBYySX3aXWEHZNE8GGDpaOyjliOuetbgrq6TE1rZFD84nW1a0hMIZn2lY1AG/MaJKQE zjHxU9V24NeXnWehVH6ERlDMA+3KPiVoVnqP9CN5PktQZO1tJ1pnXcPpTd+Fu2gkE4zUoBmbqDjxS pymF1/FC3OB9FI0huuIN/4BvggTAQwoX/AZtZWyH+JM51h9B4jn9SKk5gbieg7enClnK4lulAZvs5 Q9Ww4bnNOYB8c0p92SUB2QlERAMduCa8FI5FYdZJYvapWjhOi86zepu3UfI9KAF05ZVXfOgYwVcQp +pEFALSSg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqO-0004T7-La; Mon, 04 Feb 2019 18:19:44 +0000 Date: Mon, 4 Feb 2019 10:19:44 -0800 From: Matthew Wilcox To: john.hubbard@gmail.com Cc: Andrew Morton , linux-mm@kvack.org, 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 , linux-fsdevel@vger.kernel.org, John Hubbard Subject: Re: [PATCH 4/6] mm/gup: track gup-pinned pages Message-ID: <20190204181944.GD21860@bombadil.infradead.org> References: <20190204052135.25784-1-jhubbard@nvidia.com> <20190204052135.25784-5-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190204052135.25784-5-jhubbard@nvidia.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.