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=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 152ADC35247 for ; Mon, 3 Feb 2020 13:45:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB64522522 for ; Mon, 3 Feb 2020 13:45:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="DURGIzxz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbgBCNpV (ORCPT ); Mon, 3 Feb 2020 08:45:21 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38687 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbgBCNpU (ORCPT ); Mon, 3 Feb 2020 08:45:20 -0500 Received: by mail-lj1-f193.google.com with SMTP id w1so14709129ljh.5 for ; Mon, 03 Feb 2020 05:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IUnQxMQHK0UYauIcgeOHrO2ytoGAz4cOuFspZoniEQM=; b=DURGIzxzZtlePaPxLJuosPF5IgjZvLdBpBnJnfYw6LYoKYQi//fW9+VuRZubXpKrEs 3LMX+Dpp/1wWzauoESO6FvNHyyFvT4ul/xmaQLRrO4IMpiPr5U4TM20F1rk36BsGETrD OAVS3E71vo6UWrJIn/2DbLCgJt0lXqBdU2N+2Guw47TBqPHCoLufJi+bKVRkmIWqivfM zt/fxcxR0rw0vkfLZVGljC++AW9VE8+TNO4ilAZwM87sCtqkbKX4ppGWe913SsRoISk5 efZHmY3oSI37vKDvFb11D4iu7C2qLtXgX0OhF/qKJduP3x4bnKRRtidhdUVeVNILt/cB x37A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IUnQxMQHK0UYauIcgeOHrO2ytoGAz4cOuFspZoniEQM=; b=OuF5fzac7JSzHnlqLHpdDwxy0z3I6z20bSEAEYTcfweIbYK03Nk9YuRRzSs9XYrVKy Whmb2/oCqTtdTigCsxr7HNuAQuG9LfuOW3e764egpE0+YpmrzQfMiErk5yZehzPKluSt r1QS9vBQmJiO3U48jwjdACDGT3TFFwHQsUX1c0VJR5Eh4frIX4TaHbMqhFSA1PYTAuxr b/B2dH9xK/dtIQxy+z1hRmzZU4r05IoIZQR/PqWbc1bB9p6QdqhFYGQabbmRbRIHzt5e ovRSuYu1Clp/TUUUmq+xOxtb2mG0ngjHM6c3djqR2qZ2jhEgMT+YaBISeUw4csQN1B6H t2pw== X-Gm-Message-State: APjAAAV8j+uW87HASaL3kZuopww56PU1q/8qM3H4teA5VqMii3G/uKso X1lkj/9Se9xXmjl+N6xvt7/gnIbDQXM= X-Google-Smtp-Source: APXvYqz21QOHxuJSZYBWZNueW6EmQAJJS09hunv0rSU3v6P4mQLVjJclJr9NDXL+6UxPq3PhvyF1oA== X-Received: by 2002:a2e:8188:: with SMTP id e8mr14013556ljg.57.1580737518361; Mon, 03 Feb 2020 05:45:18 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id 11sm9941435lju.103.2020.02.03.05.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 05:45:17 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id EE551100DC8; Mon, 3 Feb 2020 16:45:29 +0300 (+03) Date: Mon, 3 Feb 2020 16:45:29 +0300 From: "Kirill A. Shutemov" To: John Hubbard Cc: Andrew Morton , Al Viro , Christoph Hellwig , Dan Williams , Dave Chinner , Ira Weiny , Jan Kara , Jason Gunthorpe , Jonathan Corbet , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Michal Hocko , Mike Kravetz , Shuah Khan , Vlastimil Babka , Matthew Wilcox , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, LKML Subject: Re: [PATCH v3 08/12] mm/gup: page->hpage_pinned_refcount: exact pin counts for huge pages Message-ID: <20200203134529.onxociznb5mgtjhf@box> References: <20200201034029.4063170-1-jhubbard@nvidia.com> <20200201034029.4063170-9-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200201034029.4063170-9-jhubbard@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 31, 2020 at 07:40:25PM -0800, John Hubbard wrote: > For huge pages (and in fact, any compound page), the > GUP_PIN_COUNTING_BIAS scheme tends to overflow too easily, each tail > page increments the head page->_refcount by GUP_PIN_COUNTING_BIAS > (1024). That limits the number of huge pages that can be pinned. > > This patch removes that limitation, by using an exact form of pin > counting for compound pages of order > 1. The "order > 1" is required > because this approach uses the 3rd struct page in the compound page, and > order 1 compound pages only have two pages, so that won't work there. Could you update the comment for HPAGE_PMD_ORDER < 2 check in hugepage_init() to reflect addtional user for the condition. > > A new struct page field, hpage_pinned_refcount, has been added, > replacing a padding field in the union (so no new space is used). > > This enhancement also has a useful side effect: huge pages and compound > pages (of order > 1) do not suffer from the "potential false positives" > problem that is discussed in the page_dma_pinned() comment block. That > is because these compound pages have extra space for tracking things, so > they get exact pin counts instead of overloading page->_refcount. > > Documentation/core-api/pin_user_pages.rst is updated accordingly. > > Suggested-by: Jan Kara > Signed-off-by: John Hubbard Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov