Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp341209pxj; Fri, 14 May 2021 04:59:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwte6DYmCBYH9iH4NSbPVTU5bUXCjreV8+QmPHKe+BidtHLsDi8hxryG3LfwW/kOjwbRNbY X-Received: by 2002:a05:6402:617:: with SMTP id n23mr56099198edv.45.1620993596698; Fri, 14 May 2021 04:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620993596; cv=none; d=google.com; s=arc-20160816; b=ZnsOKBkCro8PUFowc3cQDzQZ42epzNLJ4a9iZihpmSD0S1T5M18q+stTQAllGUmtyi ENjbepy/FD3z2q83fxEiR/rB1JHxjhiJCrLQ7COv+KwHmYM2UKeKU9grPZC3FXv+j56E SPzgO1Q4+mgE8pgxHrYHgGLCq2J/Xy7SMhijCq2nryXy68ViqbnIMWj4YsU0xSOr/jsF Z846mDVUIktpiPZbNdVeuiXLY0nbkDjbwtguRcPUExIrgDPjYPqFTCUogGTgnPZiYeqz 0YzCofxF4V7TnKhRjdSxBZO90Isq+IhZO69K+3iKfb9H52bbyU+ETIZuRDGUHh/eGeQx 4vcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=AFP6gBNkFISiPK0laICj0qHyAqGGQNbTUTj+uCieva8=; b=meGB54PP+qgjAkp6gM4uI/t3q1ket3K1iSToB5TFmTlsqfqWq6C+Vq+vClEVY333+x +aZ5ULfPeXsJawhN680rQBIojX/ANm1eLHXyZ42JWL3oStoTbzgKGb+ri8S5DEdqkLgG uXFYy36mfeqplFkCGdzn0tehCuNgilIUL5tYokA296kMjrUZ42ZeITiG1jq7UagxqlMU gyxEBdjfZgyJUN7dbBRhHLKD3HfXN6vMJXr/JFpyXCRwDluPVgLojvl/mqNA4CjbP/+1 hkdbx3AcyixQwX4KeThtmj5wnp2xIPDEiE0kx84FAUdjmKnPFff4YGIb+zvVmAgegDYN D9Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re2si5843192ejb.407.2021.05.14.04.59.32; Fri, 14 May 2021 04:59:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbhENL6C (ORCPT + 99 others); Fri, 14 May 2021 07:58:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:44578 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232930AbhENL56 (ORCPT ); Fri, 14 May 2021 07:57:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BBA08AEA6; Fri, 14 May 2021 11:56:46 +0000 (UTC) Subject: Re: [PATCH v10 07/33] mm: Add folio_get To: "Matthew Wilcox (Oracle)" , akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , Christoph Hellwig , Jeff Layton References: <20210511214735.1836149-1-willy@infradead.org> <20210511214735.1836149-8-willy@infradead.org> From: Vlastimil Babka Message-ID: <88a265ab-9ecd-18b7-c150-517a5c2e5041@suse.cz> Date: Fri, 14 May 2021 13:56:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210511214735.1836149-8-willy@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nitpick: function names in subject should IMHO also end with (). But not a reason for resend all patches that don't... On 5/11/21 11:47 PM, Matthew Wilcox (Oracle) wrote: > If we know we have a folio, we can call folio_get() instead > of get_page() and save the overhead of calling compound_head(). > > Signed-off-by: Matthew Wilcox (Oracle) > Reviewed-by: Zi Yan > Reviewed-by: Christoph Hellwig > Acked-by: Jeff Layton Acked-by: Vlastimil Babka > --- > include/linux/mm.h | 26 +++++++++++++++++--------- > 1 file changed, 17 insertions(+), 9 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 610948f0cb43..feb4645ef4f2 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1219,18 +1219,26 @@ static inline bool is_pci_p2pdma_page(const struct page *page) > } > > /* 127: arbitrary random number, small enough to assemble well */ > -#define page_ref_zero_or_close_to_overflow(page) \ > - ((unsigned int) page_ref_count(page) + 127u <= 127u) > +#define folio_ref_zero_or_close_to_overflow(folio) \ > + ((unsigned int) folio_ref_count(folio) + 127u <= 127u) > + > +/** > + * folio_get - Increment the reference count on a folio. > + * @folio: The folio. > + * > + * Context: May be called in any context, as long as you know that > + * you have a refcount on the folio. If you do not already have one, > + * folio_try_get() may be the right interface for you to use. > + */ > +static inline void folio_get(struct folio *folio) > +{ > + VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio); > + folio_ref_inc(folio); > +} > > static inline void get_page(struct page *page) > { > - page = compound_head(page); > - /* > - * Getting a normal page or the head of a compound page > - * requires to already have an elevated page->_refcount. > - */ > - VM_BUG_ON_PAGE(page_ref_zero_or_close_to_overflow(page), page); > - page_ref_inc(page); > + folio_get(page_folio(page)); > } > > bool __must_check try_grab_page(struct page *page, unsigned int flags); >