From patchwork Fri Apr 5 15:32:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13619214 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 AF385CD1284 for ; Fri, 5 Apr 2024 15:32:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 450B26B0096; Fri, 5 Apr 2024 11:32:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D99A6B0098; Fri, 5 Apr 2024 11:32:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27A6F6B0099; Fri, 5 Apr 2024 11:32:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0C7EF6B0096 for ; Fri, 5 Apr 2024 11:32:39 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D0775C03B9 for ; Fri, 5 Apr 2024 15:32:38 +0000 (UTC) X-FDA: 81975870396.12.DEEF9A8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 2D2DE140038 for ; Fri, 5 Apr 2024 15:32:36 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OeSXetSY; dmarc=none; spf=none (imf09.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=1712331157; a=rsa-sha256; cv=none; b=Lbg4nX+R6OmTMdApEbwt1t2lv49oUQB9SC84Hgh37Ylg9Vr36bMWHTIiYdVykgH/Qbh838 0lCYrPyqbN1Dgywyo9saSWjGtkrA5P2fDCKOBohjya9dgcyj9e3ZjaiL8SoBjITzWJSghd 2fz5Kz4jolDQ50L8XwRATvXDgQO1e2E= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OeSXetSY; dmarc=none; spf=none (imf09.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=1712331157; 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=KZzCy3yNnx6XbjQUrLV2VOUZ7g9S+C13lklXEbnwNVg=; b=FX8kNCUL0e0v9+l2S8XpO9zNKxoI78FT4yjcbnGdMEMrclv9O0ZNY2nBBtlR3jGXTj1PZT LrEBipuVkRuqJpfY9GuRDlzyjvoQGwyReY+HjkB1dvYrczMf0Gbz/yDBksbW0j/S+3jmU6 MNIIRcCXewUvIFqWw8GIwnTzCxwaEh4= 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=KZzCy3yNnx6XbjQUrLV2VOUZ7g9S+C13lklXEbnwNVg=; b=OeSXetSYwJHJl6y3UtpgKUmliJ wq6ROJlZ8xHZevc33YgYYTAUnwr2SpkdUxP8djPFV1SiRHEsapJF+zx7Hu3XQP8qfQbCOhon9F1do mmZBzR8rtD35oG1ByCE8RRfy2pfoQq83wMPf7M+anij+o+6U/ljzqgdhbVJwMV6VvTZeXA4kPmFgr Oz9zqidLKs3tg3A8uGjQk4UeMnylpClNVp4RqDXjRQP2+U7NzWuC0OfIWnxFiUqYCBsWBYRLfdLIO SM9BKBLb0GM92cbH0IBrDc+HJsUPYFk6v27vmZvMdeh4lQb2da+wexTvSzPZmdqECcnfjlBgEXl7k PlpLpoOA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rslYM-0000000AkxH-2ZuN; Fri, 05 Apr 2024 15:32:30 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 4/5] mm: Combine __folio_put_small, __folio_put_large and __folio_put Date: Fri, 5 Apr 2024 16:32:26 +0100 Message-ID: <20240405153228.2563754-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405153228.2563754-1-willy@infradead.org> References: <20240405153228.2563754-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2D2DE140038 X-Stat-Signature: c813ikdx3pr515w491o9jdtw1cybc88f X-HE-Tag: 1712331156-31558 X-HE-Meta: U2FsdGVkX19ArANV9arlc45D1ilpGS0fmHROuFFEFgGSgm0O3FtpvEFtN31JOTAAyiUK0C0247hVCx0gg8bXEb7Y9bt9REq1E/SL2585HsBFdE6PJjFRMkhgh0eOYRHoUqDp4d7ugjww1LgLt8iEU8EioFOj1GkN5mLZqR7M2AOjkIncymPKWThIHbggxllRxEJGJTQzc87OyL8jiDC6G8vuqyrVBZmyttlBzX93iKge+sA9lYjXP49OQqpm66+hwe56JEmaWe3Qjma7ZY5yNInX/w7520hDb1ZWG0mcdhzlFRepMZnQsL5A/ZtQed0szEQ80NuSUAS2exEH452ynS5fr+N9e/nQd7szB0CIt0Lcj556DqTC70qLevF5NjNAX5R4tK14Rmj7n2JRsFJDFdq5VyOffqjcL8X9+pyghQXVMCgFMna66R0jdHC0EgRBo+hGI9PvPO6t1qh9E/FTFxvi12uGEVrp5Ei2KZFN0Z/h8QHoZyIOUkwlY9dWEUzdC8OKpiVNLq6p+ecL2f7EXAAtvC7gX5IjBfT7ilhxlAOBPxF14GwSqwN8iGa+mOzqvYg1dBmdYZ0ZQnJ8jk232M4La0mhLqXsXgYFeE1ztdjwtH3SwxkP4UHoB/xEEYvvxU4WvdlvJgc97gAGvaEMKnbUXBUwPIKUqbxYhSLOG+29hJYgiKVEx95gOBQPR+AQrAru/ynmooy2KKLhO8kfjMLIW6tH5sY/Yp91FgCa9cddN5AZl8t0No+24HyCqiSED6m/B/UFdFXuXf3HZ450HDW2I/9AwyTP4gXdxBNDl7/ZDbNIRD7Npe5kEW2HA3baDUnzatB4njZw5U3IX60ff1gjffASoYapa5IOVZxAhlpNmZeLjTY594KzYuAE61VNNV1vqB0ZjQEvNvgeVbYffYB1A8dlWmWwGu2vLed4jX9gbM8+tSiTsxttVDepdWqAa0y79Gg+7uo5hFKSAHw vgw2amQZ bx6+e1WnXdU1wxtcOp4OdWHUflRV9UGZjhF9wnFjuumszrLwajKf4dS4C6C6eOEOrKHR2Yk/MfC37L1iXdZOuyery/7wRGdhpP8LbhmFZSMZSsObXRv+2OifHAIrvjCZEFxcwI//E1o3gdpudQ+A7SZI7CbPHqctWL5zfvDbWuI5rjfCLAdwrbZHhRcNNHw1iRpLTm5pnQyBEE9kzEhyOzD3CLbCQQ66O+xYO 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 4cfb98304742..15a7da725576 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); /**