Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1724447pxb; Thu, 4 Mar 2021 20:21:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxr1EUqOd0zGcyYdv4jwO22ZLfICtKHlI0kxY3QtFNM/wlILDK3daOcH8dckOFI9GUxXXXN X-Received: by 2002:a92:ce89:: with SMTP id r9mr6391661ilo.191.1614918086244; Thu, 04 Mar 2021 20:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614918086; cv=none; d=google.com; s=arc-20160816; b=EPY9c/+d0JcZG8akWqJ+2gioZ6RcFeXjPG+4SnwWQzWh092TAuv8lSqbijGGgWRqr1 Z7v75INPZjubAeBa39I+daUHrU6Iatj/Y/KsQevcRTvYAJ3BnPWMyHFxsRVw96QxBz8b 5cZ34yYlZCzKUjbz4x0aHpqUGPsUJlm7mwQzLWTC2fkPL1YxrV5WcOFTFWMyHSQmEydz ELXoBPGnyMuYNMszHwfGWRs8077n2YPFU3H9d16zfmxrIb1/rNpcd/aMPxPhkep4Adws 6QnZD+Q/HrNyFljwmbkbEa+PstQnHpS2l7Zf4BALd26N3iokwSUh593q9p6I7tUpnHJa 6quw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M6kHCP2ErIBVLFqPGPar7eIkGAUP7r+SY6+0x2DcRsk=; b=uuG0z91z6+o9t44UM3tQiAlMnWig5AqPgn0ccZttgv+IHrVftV6QaSx0y6Y+V8pZZA b5SE+7WRNU8kavTOHdr1kkzSg8dfgqHmKusZ7elrgNClJ9+kGNpnAsCy7B1yDpLWabCI hAHp7tObDWNMh0ttc0RLOKyWhUuBwQ1AS9P6o5golB5pX+mqkPXa0aUw7yyUGt0olnFs hOBWbsePziAzUmRhCPXbE55QlPLZWd6/QIR085CLA1UqpWvSWQBxgvVeZNR1VyZYPqH8 dOFxMYy6t8VXy3mBiUxc+Uo8f2ChbK3tu3XfEy/PfsVTVkSUtLeKctQMItqmyM6glCot U4Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BtYx3on1; 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 a22si1323757jao.25.2021.03.04.20.21.13; Thu, 04 Mar 2021 20:21:26 -0800 (PST) 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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BtYx3on1; 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 S229750AbhCEETe (ORCPT + 99 others); Thu, 4 Mar 2021 23:19:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhCEETd (ORCPT ); Thu, 4 Mar 2021 23:19:33 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 217B8C061574; Thu, 4 Mar 2021 20:19:33 -0800 (PST) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 bytes 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(struct page *page) return true; } +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 = compound_head(page); + struct folio *folio = page_folio(page); /* * 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; } - if (put_page_testzero(page)) - __put_page(page); + put_folio(folio); } /* -- 2.30.0