From patchwork Sat Mar 2 07:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13579439 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 7598EC54E49 for ; Sat, 2 Mar 2024 07:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4581F6B009D; Sat, 2 Mar 2024 02:00:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 407D06B009E; Sat, 2 Mar 2024 02:00:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BE486B009F; Sat, 2 Mar 2024 02:00:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F268D6B009D for ; Sat, 2 Mar 2024 02:00:42 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CA4DB160657 for ; Sat, 2 Mar 2024 07:00:42 +0000 (UTC) X-FDA: 81851201124.16.EF21F9F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 4A1454000E for ; Sat, 2 Mar 2024 07:00:40 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TXgg2Dk5; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709362841; 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=6+DxLmD3pWYt62PFpdwDHTX1k2S+K5LWscwMe4aPqzs=; b=aDHl8aH68s1AVWLGi9toh5+aCy6xiQXih/0zwkjS+a25QZHUT3XRnpExXrRwWDNYb6g5u6 eeN6CgnVX+7/FjS1WRGd78/NRUZAwLh/S6CIgZpvdnKvVWXk+aVxt9t4b64HJd3gJq9jZy o0OKjvW1jB3II8RbbeXsJDEPCptrWhA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TXgg2Dk5; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709362841; a=rsa-sha256; cv=none; b=SMuiIz9MJnXMmcHm8aIFbMY9d7juNfIa+4tKrHLf8uUktHGyrXzOeL2Yx3iwFcw+CHte0m cFu6aMMU5XR2ycQlNVsSaWEYAUwFNvXu2QDqI34THsVhwpLDFbULkTzBWIziWhB5Ot4b7B ssvkPiPh13GOSB80B7TtxH4lT0lgG7w= 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=6+DxLmD3pWYt62PFpdwDHTX1k2S+K5LWscwMe4aPqzs=; b=TXgg2Dk5ifnFE9JbEddiZv4xGz 4xcJCa9QlpLFsoxs0Z2CUhvTucKpQg4KVYTbGkmkU1RyjYUxcRcrqFOgPJW/OifcV4YqJqD1yY4xk PuZkHUycRenvNbP5kYkNtZdI9+OHvsRZ4jkMtLsgK0VduJC4zXmW1xHQN0ChIQKOqPRXFFgUGvWhu K8iJQ7ykZimym+u1EwMLv56QzEPUrlbb3nWd1pqPKsJpIuy1sTBoBxmZsn+THVwb/NSld4FFLILS+ H5Y0q4cKIKYsJewGULO37YWkwJDwsNgp1VpTrnJTSygZDV3C7DdRpof1x9PAkJqo4/FjS+/NZzPUL OVcqUulg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgJMH-0000000D2fe-20Xz; 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 1/4] mm/swap: Free non-hugetlb large folios in a batch Date: Sat, 2 Mar 2024 07:00:27 +0000 Message-ID: <20240302070031.3108523-2-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-Queue-Id: 4A1454000E X-Rspam-User: X-Stat-Signature: nrjep1d9bpshmzd4hemwih1yy3ktosta X-Rspamd-Server: rspam01 X-HE-Tag: 1709362840-49696 X-HE-Meta: U2FsdGVkX1+BS0KpUt3pZXTrk3dyY8990749NXSEQn8zUil1bzfyPqRkgFvaes0F772Iu++D3MtH+AqS9W5XI0oT4vWgm4SKB6oRGuupN8Rx+qfhzM0IQWCM2yE1rDmnLSwhNdkHiI2W3zJ7tIfsDgDZ7tqdIWWxrOdez4TnAkQZOwiodKB4OUE7ZoIvLDfuViFgxGDgsfZCQHEZEc/d+elhu6jgT1dovK15lD+fURTwuuMKh19idaipEs7KzTJuCF9oYZcQZ9YkAh0p21XWBN0FjdB322gScT4H1PmBpAVrm7wpqk1HMkrxunjos4bgFBMLpXYLK7B7fRW3eJf3zcC/pPln11ahMcZlZsvoNhMPTLCDi70w24D5wm8ee+hVuBF1EIYpg4ABqpyXYBtCOuzhM425UGpEwcq/U3rvFKL77F3fVv8PHWnZxb7PiyIBGm06Va2CrFE1Iuy3Kf74veupoE/VnSr5iH8PSkj02zJnF3vktEJfjIbZTPKlviBMPPVxZxFshMAPNJmlevARgonMKOPPGu8b0PKSLUF3d+mxRCrtkfZ4jklbvd3CshXQaFujfbucenA+IQtomVrFZ7HkI/ueysK7SjJjki5edFABY07tJ+LUKn4ENVk4enx9l7ykR83/uBTIUvmCjKU7ix2mnbbcj0fbkKR96KvVYBStNJQu4PebWR0HVh/0fY9bF8aPtoieewGiFFZtNWW1nOo1GReUdpzAq3jwlF6Snz6Cc1RsFMJCGpK3f1bffqTiGnElLQjQe1Y99MBuJSvINle12l5w9SjJOQnUPXrK+d4soRLaphYzYZrAceDFWJblSQ5AMYsRodZ+udWGY++e6gL6mHqN5I61+qBgqltboPFOMUXunmT+tQ== 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: free_unref_folios() can now handle non-hugetlb large folios, so keep normal large folios in the batch. hugetlb folios still need special treatment (and I think they can be freed this way). Signed-off-by: Matthew Wilcox (Oracle) --- mm/swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 6b697d33fa5b..d1e016e9ee1a 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -158,8 +158,8 @@ void put_pages_list(struct list_head *pages) list_for_each_entry(folio, pages, lru) { if (!folio_put_testzero(folio)) continue; - if (folio_test_large(folio)) { - __folio_put_large(folio); + if (folio_test_hugetlb(folio)) { + free_huge_folio(folio); continue; } /* LRU flag must be clear because it's passed using the lru */ From patchwork Sat Mar 2 07:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13579441 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 601E5C5478C for ; Sat, 2 Mar 2024 07:00:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E935B6B009F; Sat, 2 Mar 2024 02:00:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E42016B00A0; Sat, 2 Mar 2024 02:00:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE3506B00A1; Sat, 2 Mar 2024 02:00:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B62376B009F for ; Sat, 2 Mar 2024 02:00:48 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 99E991A0614 for ; Sat, 2 Mar 2024 07:00:48 +0000 (UTC) X-FDA: 81851201376.13.7DF0EE6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id EB61340020 for ; Sat, 2 Mar 2024 07:00:46 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N34Y3B6g; dmarc=none; spf=none (imf27.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=1709362847; 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=Q4z2pCHKerviP2W/GaaEWBolh6vlgWiXDx5cDUrL/+8=; b=lVGmD8KFWVjwY3Kq0b7VHoXGXUPEfnIsEiTQJjDvucG6JgGc506GlLHnbp3hYjkHnmnWrH GUzuEPQsI2Dvdxvxv35hTqAp2CppNchE1kwPSzh4A/gDF///0WY2B9oX79jrY3S8HWk/ki a6Nt0mC7M+Q1qTWH00xUdnF7zZ9VbCw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N34Y3B6g; dmarc=none; spf=none (imf27.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=1709362847; a=rsa-sha256; cv=none; b=DDa6XftSU9XnGeiILL8I2wmO5GUQHo+uj92QyEOgUsJsE63NihQinXXq4cz5ur8av5iRQF 5NL/MsKAswa94STUypw5oni0GyJpiuvyKb+t0nWJ9WZL1lsaeJnaTeFPNth+vJeRoYGJS9 cqm+imQDQdEwW5hSulyE3+E/icw6psA= 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=Q4z2pCHKerviP2W/GaaEWBolh6vlgWiXDx5cDUrL/+8=; b=N34Y3B6g74GhM2XhLX22H3kscZ KLfYWAGBqrM68cets6KKAkvjMBmCC0aV4Gdgsvb9S75BjBEQfku6aeI+y48efuSn1DQd6psqCrv/w gOhsPPaLJKm23kDCKr7hqV39E8rwBeVql5ieDfEAIs2APjQW9FTpg6HEKX83Zh/0N91tlrbB0HAPu aaQSTvteoszZb0I2zyV6fyD8vROU8aA9wG0WXDcE+nuOIdISvmpVq3mE5FMvHjVChAZXoL4snLQUf +xQeLzuj3LlJLFmozInBqU5afPJNdBp3WgAs5BzwajR+E1zVGvrX+w1xAxWGNdcsyFxup2MWP5Rlh TMXD2+1g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgJMH-0000000D2fg-2JuH; 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 2/4] page_alloc: Combine free_the_page() and free_unref_page() Date: Sat, 2 Mar 2024 07:00:28 +0000 Message-ID: <20240302070031.3108523-3-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-Queue-Id: EB61340020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6rzkzmg8zrbcirp1z4gttibceyekxkk9 X-HE-Tag: 1709362846-928208 X-HE-Meta: U2FsdGVkX18YXrXbIDi2Dck4xXHqlwvfstxkC0qUnX3q5BoguIJYI3faVbBmWFuNibuJoP4FHDyXHEnbay9c3H1wXlLFNJtfXupBYX7ASsCrfk22Nv5ar3PMQdbFKsZQqDwThzo7Va+YjA2oJq5G1A4D2ILDNWVjMjV60uLg6iJ/QkTUD3D8RQmRFeTLi79eg73zERpTZMUAoIr8wsrOROsGEZgR9w3fEV524vA8CYANj0aHWeifr0eY50aJ7hgpf/Y3TxvsE0Xx48w/9JYVK3vlvQ71bIfLlv3RGWXKsGOvPcqc9h+ybNOfzxb9BsazrE+d0wUxqL9W1S6yIopdZ+s+8JKRm96sm0G1MHJ89m+3O3HQK8jexGXDe/16/zatPcrGQTHgAMR1I65Kb+LgXRi4omr04/LRUQWHTCN0pxg+E2zN+u1vsYp2GwKIMrMjvpYHKJM/MTHoOlKMsKfCp0wdpv/TEhLXqIC/c7hiYFwv7mD+Zku57JmU8jflXB+WsDC8W9HcgSW6NRvI8rKPq0AI3OFktw8v4hLClPEAH8LXDWIHwPAmAj6rJQEb3SRcs1dDeo2IvD2Di6IgFVYqfj5dZjcHhEhRX1Bl5spLNVuxtF0y4biw0bIzMGVPmcXJIY+sjLF/8RbGhZcyPullcbjEy3m5ToDQxnel0dNdilOvwBsWJfqgPhF4mu1N+OS2mkQ1q5xQuFHmSoxdmrhQnkA1i/iVvnr1Ag/JovLYKyZ7gWYTel8Q+Pyxu2iKBP6fOmgsbEJHlLR4nHICNEMGqBncPhq3xHpV3/DtHy8uQE3DgoBUl541yqaABXkCYYkOtSYg3CD/TUql7i77OqdGIOCBkkza7lAGrAKB0okhw2cmcCSa69gAoymaz/4nn3UO8r6mDc+/8J+/TLkrwycaJHAoNk7s64xeiKJpWW9JYftuvVLrE7glMjOk5L0n/ueXXLglCC1GfqkZk+aWj5W aBihU1tw fBX8HKSk3ClEzeGRB6NZ1a4WTmfeo0Gktn44lPdAuwWfu599AYKnYRL/9rHRa2rKjMxgv6ArIyOD3n7enAEwnmFmYMvzkFSIX4CNMJWprQE7DDasAm7nH4HgCY7l6/fv5Yf4Z9f14ZLo4xr0Y8Lrc26rLcEleIfR4L7NfvBcV2moeJGN1aPTOpEDQIVQl2yTTm3MzYTswM4BuI5zq7r+y/BPkfEJIFUGqqKxJ 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: The pcp_allowed_order() check was only being skipped by __folio_put_small() which is about to be rearranged. Signed-off-by: Matthew Wilcox (Oracle) --- mm/page_alloc.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 16241906a368..a51cbae62501 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -558,14 +558,6 @@ static inline bool pcp_allowed_order(unsigned int order) return false; } -static inline void free_the_page(struct page *page, unsigned int order) -{ - if (pcp_allowed_order(order)) /* Via pcp? */ - free_unref_page(page, order); - else - __free_pages_ok(page, order, FPI_NONE); -} - /* * Higher-order pages are called "compound pages". They are structured thusly: * @@ -601,7 +593,7 @@ void destroy_large_folio(struct folio *folio) folio_undo_large_rmappable(folio); mem_cgroup_uncharge(folio); - free_the_page(&folio->page, folio_order(folio)); + free_unref_page(&folio->page, folio_order(folio)); } static inline void set_buddy_order(struct page *page, unsigned int order) @@ -2520,6 +2512,11 @@ void free_unref_page(struct page *page, unsigned int order) unsigned long pfn = page_to_pfn(page); int migratetype, pcpmigratetype; + if (!pcp_allowed_order(order)) { + __free_pages_ok(page, order, FPI_NONE); + return; + } + if (!free_unref_page_prepare(page, pfn, order)) return; @@ -4694,10 +4691,10 @@ void __free_pages(struct page *page, unsigned int order) int head = PageHead(page); if (put_page_testzero(page)) - free_the_page(page, order); + free_unref_page(page, order); else if (!head) while (order-- > 0) - free_the_page(page + (1 << order), order); + free_unref_page(page + (1 << order), order); } EXPORT_SYMBOL(__free_pages); @@ -4748,7 +4745,7 @@ void __page_frag_cache_drain(struct page *page, unsigned int count) VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); if (page_ref_sub_and_test(page, count)) - free_the_page(page, compound_order(page)); + free_unref_page(page, compound_order(page)); } EXPORT_SYMBOL(__page_frag_cache_drain); @@ -4789,7 +4786,7 @@ void *page_frag_alloc_align(struct page_frag_cache *nc, goto refill; if (unlikely(nc->pfmemalloc)) { - free_the_page(page, compound_order(page)); + free_unref_page(page, compound_order(page)); goto refill; } @@ -4833,7 +4830,7 @@ void page_frag_free(void *addr) struct page *page = virt_to_head_page(addr); if (unlikely(put_page_testzero(page))) - free_the_page(page, compound_order(page)); + free_unref_page(page, compound_order(page)); } EXPORT_SYMBOL(page_frag_free); From patchwork Sat Mar 2 07:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13579438 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 E1FD4C5478C for ; Sat, 2 Mar 2024 07:00:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1F486B009B; Sat, 2 Mar 2024 02:00:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD0136B009D; 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 A96AB6B009E; Sat, 2 Mar 2024 02:00:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8B6456B009D for ; Sat, 2 Mar 2024 02:00:40 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CFD6D8065C for ; Sat, 2 Mar 2024 07:00:39 +0000 (UTC) X-FDA: 81851200998.16.5129E17 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 62CE9A000E for ; Sat, 2 Mar 2024 07:00:38 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XQc5W0yi; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709362838; 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=P6Vo8WTO8b4LilggPskpKKneeK4Jr+pGiDxU0jDjxQw=; b=hHFYrX7+GbfMfSH+xmikftY5R+//F6JJ8MZnfVKAZoX4rOI6/P61v+7MIjDj7sLgJwrn5S VDgUi0VuKoqceozZNMNFAB2AoQrLQTerDls22jp02n7qYqsKM7JJB3apDj2LLOA3GE1/mo rhqSEuRvI4snAB7V5wulzaozAwpewOo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709362838; a=rsa-sha256; cv=none; b=tr2SoC1g/r7FtW1IolExk12f9LM2MY67iwDm+27TtMtGNBrW20evvQJhUvJnbrZ3uAHbw7 H4IxwzAFCg0T6K3NbCyY46fiY/ZJsg9NgrlCkX4tz5jWb9N4a9ISEezZfQEX8FFQtlzZxa fSxDk4E0ogx6UaRKlaRR78k8IpKVuhc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XQc5W0yi; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=P6Vo8WTO8b4LilggPskpKKneeK4Jr+pGiDxU0jDjxQw=; b=XQc5W0yiEYAbX9mQX8VXlgBr51 IWwGniKZyjbwaIuAQUn0mQrjitvhYKnmTHS7XWBXL6LGMBR9oW77tc0Q6NHYuYbjbEay87OIy3gHA W6x/zg0NNMlL9AOlVTLm8NpHUIb0GNveD5hwFZo4k4AuJ/x6QolBrgxU+69AdlrzgoCqkpc6YkKnY zl9M+v5dGZiPiEseX8S+T5Q7wzAI5YOKfulWURCXdNC+wv8pN6xBypolUv9d6lY7jpuWK304M1fuF vGGDXb/w3DltU40WHhv+ZiZIkbsd3tL5YGLrhnGxdGLf7h3MOojyu0h7mQyhfOC2AyyVe16e5O3OS P01D3s3g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgJMH-0000000D2fi-2ZpZ; 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 3/4] page_alloc: Inline destroy_large_folio() into __folio_put_large() Date: Sat, 2 Mar 2024 07:00:29 +0000 Message-ID: <20240302070031.3108523-4-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-Queue-Id: 62CE9A000E X-Rspam-User: X-Stat-Signature: j6a7r1bofsfsnyquexyho4g8hkjn3gi4 X-Rspamd-Server: rspam03 X-HE-Tag: 1709362838-33931 X-HE-Meta: U2FsdGVkX1+4TqpgFnWh2ZZ5J2v/ASWQgjMMk4ZKmU8D5Q12PfL9CY1AP1h3DPt5+QDluAbM1N+EPWayExmU71KJfXzgk24OSpXJ5caxD1sq6MsPQpLF0SdSeEVPIqrR207/W61U9HfjlQfjf3gURvYqjWd6/G1k4Nw8g7EqAU6KxM5ukQNaMjW9VjLMVlf0Lzur3QyDgsZORSeXgUKUm1RcyV/IyqPlvhtpOQs114I+T/ljEEVyE3HLKeKi7HNO07aT6S7EHPH6k3iE+JY2ZTgPymvlPZG5Ys/sy6QdDgNqHd9ODFmBOz+YP5+ayv7bpXRmQMek/PFy+SIiqhkvsM0lXdXvhXmuTVmYQCmvo4WLkcytfsin6/6f+/QIufWJIZPrPWb6WqLp7nkONtEa2MG/eeDqhc2ADYypfMS4E6S2eXXTkVt7Z5pZO/6qY8MUGSUVw5jBc+thp04wpMVwJI0xkcDRJzCAeOHQjLjvWGJ4vcqsT2vnajDvSxnCnBj+28IJcdSGzfDKM5V0CIoOUn4oOErs/Fn9oyBs2ta2SZCAUejLNku/VAPLIY6v5SJNrFbgoalfBI22eIMheAV06FmiX61Sww2ji7p54jVqLuALjQDc14w7JuW98xAUbje1L50mnjCyAl62qXhdrDMp4Xp1sWfKigO5e2of21KQVdGAKUFmqQ/2Wfh4PaF4CN4yLSGbp0LEvlpt58ADgDHi2DCKssQKKmnpaUhg2QTAUnzkotxb65NsnmspRIC+fs/dDIlmfBlEKGGNzbcEw78v+YbW8wLxMDxLVhrj5M63hWFFWYlQVlegasaMeQ39SMndnRQwKr8Wc/maA9Yo3D8AJymCuBOl4D4mwnkPv1RgRI8Z6ZayS0YylDGgPDycGeOC0tF/qAb3YxuS/2rkn3EGQ/Rscyx4/pQo 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: destroy_large_folio() has only one caller, move its contents there. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 2 -- mm/page_alloc.c | 14 -------------- mm/swap.c | 13 ++++++++++--- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index cfbf2bbc6200..9445155a0873 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1315,8 +1315,6 @@ void folio_copy(struct folio *dst, struct folio *src); unsigned long nr_free_buffer_pages(void); -void destroy_large_folio(struct folio *folio); - /* Returns the number of bytes in this potentially compound page. */ static inline unsigned long page_size(struct page *page) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a51cbae62501..8d1f065f6a32 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -582,20 +582,6 @@ void prep_compound_page(struct page *page, unsigned int order) prep_compound_head(page, order); } -void destroy_large_folio(struct folio *folio) -{ - if (folio_test_hugetlb(folio)) { - free_huge_folio(folio); - return; - } - - if (folio_test_large_rmappable(folio)) - folio_undo_large_rmappable(folio); - - mem_cgroup_uncharge(folio); - free_unref_page(&folio->page, folio_order(folio)); -} - static inline void set_buddy_order(struct page *page, unsigned int order) { set_page_private(page, order); diff --git a/mm/swap.c b/mm/swap.c index d1e016e9ee1a..d8c24300ea3d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -127,9 +127,16 @@ static void __folio_put_large(struct folio *folio) * (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)) - page_cache_release(folio); - destroy_large_folio(folio); + if (folio_test_hugetlb(folio)) { + free_huge_folio(folio); + return; + } + + page_cache_release(folio); + if (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) 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); /**