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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 C5551C43460 for ; Fri, 14 May 2021 11:56:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6F88C61406 for ; Fri, 14 May 2021 11:56:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F88C61406 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 09BB66B0036; Fri, 14 May 2021 07:56:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2C976B006E; Fri, 14 May 2021 07:56:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA5986B0070; Fri, 14 May 2021 07:56:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id A14C66B0036 for ; Fri, 14 May 2021 07:56:48 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3B56DB9EF for ; Fri, 14 May 2021 11:56:48 +0000 (UTC) X-FDA: 78139684896.05.3624EC2 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf27.hostedemail.com (Postfix) with ESMTP id 4F11B80192EB for ; Fri, 14 May 2021 11:56:46 +0000 (UTC) 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 Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4F11B80192EB X-Stat-Signature: d3rsqms5qndaa6xypqxqenkzys73sek7 X-HE-Tag: 1620993406-781492 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); >