From patchwork Sat Feb 17 02:25:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13561203 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 82184C48BEF for ; Sat, 17 Feb 2024 02:25:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5506B6B0096; Fri, 16 Feb 2024 21:25:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BB966B009C; Fri, 16 Feb 2024 21:25:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 022EE6B009B; Fri, 16 Feb 2024 21:25:53 -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 D32526B0098 for ; Fri, 16 Feb 2024 21:25:53 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1D30D80139 for ; Sat, 17 Feb 2024 02:25:53 +0000 (UTC) X-FDA: 81799705386.12.58C43BD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 9BF024000E for ; Sat, 17 Feb 2024 02:25:51 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hkPTBK85; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708136751; 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=AeeOyRTuCkQBvJfx3AB0GRUPqnlTrrPrtcTW/4ajnA8=; b=R2k01zjinIsk/jiIFZpkbBOWSpdj+cq0w29ydZNjit7FdkmknOX3xEO2OXdNn6+HytxlIP mwr4roM7SXhQcZdRdPPpNsIWGm+iXqsFrDTfKeUGT4KUwNEYTtPfysHr1VC6uSegyOJtrO c75Qg74d1kzUTKBtLfpE9vibD7TUrMg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hkPTBK85; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708136751; a=rsa-sha256; cv=none; b=nEyEZvroHiYd+jwqBOK5Ne0lQHirtdWz4AJ60xAU+jpWpbk4g87DA5teaaSNQihbxbcqVh xip1IpRs/cnr7Y4qG2RFmbcMHRXGhs2pqU0wQ78sOiL97076pZGbEzmIns3hUDiGNBn5K0 clad8sE+cOe6iejj0EopxC/07x50Dfs= 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=AeeOyRTuCkQBvJfx3AB0GRUPqnlTrrPrtcTW/4ajnA8=; b=hkPTBK85XC/Z0XtdzHiO4CQvuH rSYDAY2pBa/Hg+ZMTygcrKERy/WOGbTsqSPCmRiE+QRqduGSsbbsW3PJOt7vHzbD7952iRZ5E4L0c 7MRQPdguDVqYxyZqMnjU4Xw+j2jSwWeaF/pQR5nBlxTnPXRjV9234Lj0eBNd86NypLRS5WSosqLMn qR3PFH7jYOUPxhE8norcB0Rz8K8cgmIIV8jEFveLXdsrrGPVZ8x4taYg8ww7gEKgTXk12gkgz89Dg wMQyoYJjVQ8cj0O6t+m8QxGLf5HpEy0TpC6oLa3f5OCcMz61H4apUlOx271UuwA67uiNNq9R0T18M M+ngpCJA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbAOk-00000006HEQ-0bdW; Sat, 17 Feb 2024 02:25:50 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Ryan Roberts Subject: [PATCH v2 18/18] mm: Convert free_swap_cache() to take a folio Date: Sat, 17 Feb 2024 02:25:44 +0000 Message-ID: <20240217022546.1496101-19-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217022546.1496101-1-willy@infradead.org> References: <20240217022546.1496101-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 65cdngdd8qftdgqf7y8e1un5m8g8wsdc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9BF024000E X-HE-Tag: 1708136751-656372 X-HE-Meta: U2FsdGVkX18TKCurtZqOVYvsv5YjnJCIJEnQwh2xixgC0NVvKSXcm0IT2t94EWSE+YxE6YWNvW58VHky0X7nT1Zf87ogcOnAbKs4jkHiGrmMYFh2t35LvsylfyRo592cJHC4/EuUv/Osf3NUsQQpkPi/5iYWvbKFCGMm2AZD7SLzI3KG7JiVJkaEp+p0T6bQAmUu28n99PiYZfJdNjH5sjWtvycJ6GdGkpdlO3e35WVJ4MWieThxITiC5PRnFw/i48W1Ol01PJ4dz9k12JNRRImwhiHFAF0Z/Bgh1BVTM3BvrgvU7QsWeg/Z3W3lFVt6b86JGlkI0ly/cYEz9fgmtU+DKq3mTDqxHB/jfIcDjsk4wEDqLfJEZSkFGOTjb0M1iS+oGnekRMpfWQ7mwsoKyrnvCHVbQu49Pgnp47v2iXSxl1p6R2uHjVS2lfa2tYtA1ujM8UKZ2iWnAzpNJq2G+n421o5rKU+2VJrVnILH06/doNtd3L2hX7ICPCIRmk32ZSZmh80jc4PpWnpq+JHyfiEbQOWdzGcKFsBTKOP1MLvEtGUGu9/TIQNastg6wuQguV9osNgurT0TUZWGSZNWChcr1paq/PoOtWU7xJPXKq/0DIbnSkEhckVzVsx0uDCiDcs84Mdq7moeUqA6u67IFKo4zhmmA7r0TRzs5MbTsrFgTA2L/BbDugdBXXTCltoXMZoybfctFrfP3zV0fwkOmXVXGXSkTjei5hCTz0xviQEgAAhpj4XysVyWFtjgX2CMA5AvjOpFK23aKsIZmrVG5VkW0689n9elXRcaA4R8CWvPJdhU/1NXvWTmrYkRgKycGT+WfMuRC70OW/kmlMFoaGA2qixXEwzENxJhFKxifuPigYBS0WAnFYKLd7sqv5Tuyih+RtSm6FCRlcNyQFsYaT3CK+jXoN1UpIJUN0ui0yU= 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: All but one caller already has a folio, so convert free_page_and_swap_cache() to have a folio and remove the call to page_folio(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Ryan Roberts Reviewed-by: David Hildenbrand --- include/linux/swap.h | 8 ++++---- mm/khugepaged.c | 2 +- mm/memory.c | 2 +- mm/swap_state.c | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 3e2b038852bb..a211a0383425 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -440,9 +440,9 @@ static inline unsigned long total_swapcache_pages(void) return global_node_page_state(NR_SWAPCACHE); } -extern void free_swap_cache(struct page *page); -extern void free_page_and_swap_cache(struct page *); -extern void free_pages_and_swap_cache(struct encoded_page **, int); +void free_swap_cache(struct folio *folio); +void free_page_and_swap_cache(struct page *); +void free_pages_and_swap_cache(struct encoded_page **, int); /* linux/mm/swapfile.c */ extern atomic_long_t nr_swap_pages; extern long total_swap_pages; @@ -524,7 +524,7 @@ static inline void put_swap_device(struct swap_info_struct *si) /* used to sanity check ptes in zap_pte_range when CONFIG_SWAP=0 */ #define free_swap_and_cache(e) is_pfn_swap_entry(e) -static inline void free_swap_cache(struct page *page) +static inline void free_swap_cache(struct folio *folio) { } diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 5cc39c3f3847..d19fba3355a7 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -731,7 +731,7 @@ static void __collapse_huge_page_copy_succeeded(pte_t *pte, node_stat_sub_folio(src, NR_ISOLATED_ANON + folio_is_file_lru(src)); folio_unlock(src); - free_swap_cache(&src->page); + free_swap_cache(src); folio_putback_lru(src); } } diff --git a/mm/memory.c b/mm/memory.c index e3e32c5b4be1..815312b2dc48 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3376,7 +3376,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) folio_put(new_folio); if (old_folio) { if (page_copied) - free_swap_cache(&old_folio->page); + free_swap_cache(old_folio); folio_put(old_folio); } diff --git a/mm/swap_state.c b/mm/swap_state.c index f2e07022d763..3f58d6fd5b44 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -283,10 +283,8 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, * folio_free_swap() _with_ the lock. * - Marcelo */ -void free_swap_cache(struct page *page) +void free_swap_cache(struct folio *folio) { - struct folio *folio = page_folio(page); - if (folio_test_swapcache(folio) && !folio_mapped(folio) && folio_trylock(folio)) { folio_free_swap(folio); @@ -300,9 +298,11 @@ void free_swap_cache(struct page *page) */ void free_page_and_swap_cache(struct page *page) { - free_swap_cache(page); + struct folio *folio = page_folio(page); + + free_swap_cache(folio); if (!is_huge_zero_page(page)) - put_page(page); + folio_put(folio); } /* @@ -317,7 +317,7 @@ void free_pages_and_swap_cache(struct encoded_page **pages, int nr) folio_batch_init(&folios); for (int i = 0; i < nr; i++) { struct folio *folio = page_folio(encoded_page_ptr(pages[i])); - free_swap_cache(&folio->page); + free_swap_cache(folio); if (folio_batch_add(&folios, folio) == 0) folios_put(&folios); }