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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 85B3BC433E0 for ; Fri, 5 Mar 2021 04:19:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C7D464FF0 for ; Fri, 5 Mar 2021 04:19:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C7D464FF0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C2FBE6B000D; Thu, 4 Mar 2021 23:19:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BBA7F6B000E; Thu, 4 Mar 2021 23:19:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A335C6B0010; Thu, 4 Mar 2021 23:19:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id 83F9C6B000D for ; Thu, 4 Mar 2021 23:19:33 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4DDDB364F for ; Fri, 5 Mar 2021 04:19:33 +0000 (UTC) X-FDA: 77884516626.20.C40DFDB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 6BC70C0001EA for ; Fri, 5 Mar 2021 04:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=M6kHCP2ErIBVLFqPGPar7eIkGAUP7r+SY6+0x2DcRsk=; b=BtYx3on1gAjsZVKoYT5FUu6v1a EM/Rq722gHomS4jffeqmg1qCOPQ3GOB7fJHzuQhCgBrMckl8DVZEtA+XQTEvlXZInbF1+iRJaT6bg 8JCeAdRuleiE8u0XQtFMkcKSQKQClhQTFCxIEI4kQen8VzaQ+EIkUt8jXUqzew4jEL6NrHfeI1gV1 mM50ZICpfcjvM15fTiI5Td0yb5iK0naAb+HBVoEqWVIJ3EynFXLoT537u+r6BtjTMOiB4Exd4seWS 6/z4b9wZZ+HXyla9cicOdUN/ax8VBu5NCCeYG2aFHOxRpVEKfrbEYSFRpbeAIuJfQ6OwkXKxj6qJk PJnEd3kQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lI1vr-00A3T3-LO; Fri, 05 Mar 2021 04:19:22 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Zi Yan Subject: [PATCH v4 05/25] mm: Add put_folio Date: Fri, 5 Mar 2021 04:18:41 +0000 Message-Id: <20210305041901.2396498-6-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210305041901.2396498-1-willy@infradead.org> References: <20210305041901.2396498-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: 8u3s3qnycc6spnis1kj6dw4187dazqn1 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6BC70C0001EA Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614917972-549223 Content-Transfer-Encoding: quoted-printable 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: If we know we have a folio, we can call put_folio() instead of put_page() and save the overhead of calling compound_head(). Also skips the devmap checks. This commit looks like it should be a no-op, but actually saves 1714 byte= s of text with the distro-derived config that I'm testing. Some functions grow a little while others shrink. I presume the compiler is making different inlining decisions. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Zi Yan --- include/linux/mm.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ecfe202aa4ec..30fd431b1b05 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1205,9 +1205,15 @@ static inline __must_check bool try_get_page(struc= t page *page) return true; } =20 +static inline void put_folio(struct folio *folio) +{ + if (put_page_testzero(&folio->page)) + __put_page(&folio->page); +} + static inline void put_page(struct page *page) { - page =3D compound_head(page); + struct folio *folio =3D page_folio(page); =20 /* * For devmap managed pages we need to catch refcount transition from @@ -1215,13 +1221,12 @@ static inline void put_page(struct page *page) * need to inform the device driver through callback. See * include/linux/memremap.h and HMM for details. */ - if (page_is_devmap_managed(page)) { - put_devmap_managed_page(page); + if (page_is_devmap_managed(&folio->page)) { + put_devmap_managed_page(&folio->page); return; } =20 - if (put_page_testzero(page)) - __put_page(page); + put_folio(folio); } =20 /* --=20 2.30.0