From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC203C282C4 for ; Mon, 4 Feb 2019 18:20:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F5342082E for ; Mon, 4 Feb 2019 18:20:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="uSWLen75" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729206AbfBDST5 (ORCPT ); Mon, 4 Feb 2019 13:19:57 -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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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.