From patchwork Sat Mar 2 07:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13579437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A163C54798 for ; Sat, 2 Mar 2024 07:00:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73F546B0092; Sat, 2 Mar 2024 02:00:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EE026B009B; Sat, 2 Mar 2024 02:00:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B4C76B009C; Sat, 2 Mar 2024 02:00:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 47AA56B0092 for ; Sat, 2 Mar 2024 02:00:40 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EC35E80668 for ; Sat, 2 Mar 2024 07:00:39 +0000 (UTC) X-FDA: 81851200998.12.A340D16 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id CA2F9A0020 for ; Sat, 2 Mar 2024 07:00:36 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XZQmrDsL; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709362837; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=z+m+c1hY1yLW2Rh4sf/hDCQOC5TX+A2njYAOKJN0cVo=; b=O+p0KgRNpFukvPp3Uo1mwgPP9mwE6kM2pJ9cmWBnchoPJDSZALPw5uV/j8dFCOZ3TmVlvq MzBEZQdqOZJaJk49bGbvZve+W4bvLeHLeGsFMNRqsS5wuLsAQcgl7rYkuLcDcy1pLqCLKh LXKs5vI20p5NHGBSlZM1na4TwLb+2dg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XZQmrDsL; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709362837; a=rsa-sha256; cv=none; b=s3ArRTnw7arvc5EPLyNw5/7Y5d/d2F+cwOw4qXoWITaBCgjPAkpmUm/zjssHKYf5jg6qXV 9R+GGyprdY6dm8gPEYpIb8rO8yCFwj2ZAeo+lmGh1x68EUNDDb8svfIO78ERUrwx9r+WCo yWu9qKd0sJcdhw7GY+pTn23Ojv06x3c= 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=z+m+c1hY1yLW2Rh4sf/hDCQOC5TX+A2njYAOKJN0cVo=; b=XZQmrDsL88nIAkjSRZ9brfV9IJ 38MzKRHIeFu9bvBct+WycBb/n0oU5zRxwOBiF1dQpCHjrlWXonL1CbIvccqI5iZj3eiEKWP5pSBhs T02uJyegnhOtLLhqGKkSveQFSWkIIfugEtmPoUY2H7wh2ju5QtgrX4Tr5+BT5Cm3W2ieC3/gSBGBN 4apgZxpAw3xcJDbK/UgpDotidPrf4ApGXVFuMvEKwBXLtk2AP/wR3adI4nbhjOesPnE2ZfVcbaDM+ qV95+HzTMWKIlRRTvnFgYcv3hAlrX2Aa1iQgfbE8BeY9CLHj5LuezCwuzTamuAdzTuzS4HkqA9rmD f7a3hVhA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgJMH-0000000D2fk-2qn5; Sat, 02 Mar 2024 07:00:33 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Kent Overstreet Subject: [PATCH 4/4] swap: Combine __folio_put_small, __folio_put_large and __folio_put Date: Sat, 2 Mar 2024 07:00:30 +0000 Message-ID: <20240302070031.3108523-5-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240302070031.3108523-1-willy@infradead.org> References: <20240302070031.3108523-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CA2F9A0020 X-Stat-Signature: foe9e6h9xr7wsm3h9oakfmf1wm3na3yd X-Rspam-User: X-HE-Tag: 1709362836-429055 X-HE-Meta: U2FsdGVkX19WeGZ8h4xmtlUFzBaPkFPGZBDlsSpJzD2MiTdMXcv7F5twOSCYrJxv1udntrOPzXEzYcgEEu67A/CRNaNV9zr4zHPXPnNgQzqxRAvOEYQzTAYpeRcNNFD49lIBWhMnd6SJkMyiOjf22YQS9sDq14JlmiR4jOa8n3nFv/ZybIHnAw3q10cbGjaJA+aXKbM7kGWuH2Ws+rh7g4XRBH8PU0QtT9XQ9LpxIodRQw683QIZe6KGfpcziDqKQBwB1f9XtFtM8pwHttv9QhX/ymbLVzw3UCxly2BqIlBgjpJGRWodp3T/bddwf2rEux9oOMrPruzbfPvHkcl4DQEUShgDMGiuI6YPRxQmB40g308S2H4VSc92LtDibNzCwfEjqWyJDqqF8r4uQ9UK1wc97OdmlqNSUYBvN68pf53PjB5gMmALgLRVsJjF+va9JxrqopU5YkFQVYS1ntdZmLXh0Wd/aa3URHEwr3oevTjQh7Sk6b53KXd61lmCrvz4u/ymYvVFtw8AYsLo/ipCYox4eZuhTjwnB/RLeK0dimVZzlPvkUzkUQZVKXEuqMc3/K0tz1jp/r7akF1q1eLfp08s7qcXzEpkn42y/ZR2ofY8YAaVUnFdLQqKFVLwx4ypLwfBIaUrmuMRa0+FPlz5skV6rIFo8ARwIXsvmFtiG9BbIORTamhzpfMXNYY55H+pXYgjQ4POkCAlB0e5AG9OSCMlOnxBuQXjj2Ao5lndgTlr8BXxalHN7pW1ZfxKuDVjvunb7ePi2VmVoBVKOkIAIHfZllJWiC/WgnhHyvav8WehSrf3lIRs1fqHD6qx64rgpFp6yGOKQcnoaUYISBZcDHVzXh9XqkFJIZ9LWb1pH/05Dn6AbB1PPCYv1a3bk/fB2Kr/kD4ir/C2+z1zrU2zk3V+64v1MBPY 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: List-Subscribe: List-Unsubscribe: It's now obvious that __folio_put_small and __folio_put_large do almost exactly the same thing. Inline them both into __folio_put. Signed-off-by: Matthew Wilcox (Oracle) --- mm/swap.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index d8c24300ea3d..a910af21ba68 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -112,42 +112,22 @@ static void page_cache_release(struct folio *folio) unlock_page_lruvec_irqrestore(lruvec, flags); } -static void __folio_put_small(struct folio *folio) -{ - page_cache_release(folio); - mem_cgroup_uncharge(folio); - free_unref_page(&folio->page, 0); -} - -static void __folio_put_large(struct folio *folio) +void __folio_put(struct folio *folio) { - /* - * __page_cache_release() is supposed to be called for thp, not for - * hugetlb. This is because hugetlb page does never have PageLRU set - * (it's never listed to any LRU lists) and no memcg routines should - * be called for hugetlb (it has a separate hugetlb_cgroup.) - */ - if (folio_test_hugetlb(folio)) { + if (unlikely(folio_is_zone_device(folio))) { + free_zone_device_page(&folio->page); + return; + } else if (folio_test_hugetlb(folio)) { free_huge_folio(folio); return; } page_cache_release(folio); - if (folio_test_large_rmappable(folio)) + if (folio_test_large(folio) && folio_test_large_rmappable(folio)) folio_undo_large_rmappable(folio); mem_cgroup_uncharge(folio); free_unref_page(&folio->page, folio_order(folio)); } - -void __folio_put(struct folio *folio) -{ - if (unlikely(folio_is_zone_device(folio))) - free_zone_device_page(&folio->page); - else if (unlikely(folio_test_large(folio))) - __folio_put_large(folio); - else - __folio_put_small(folio); -} EXPORT_SYMBOL(__folio_put); /**