From patchwork Tue Feb 27 17:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13574211 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 3F09AC54798 for ; Tue, 27 Feb 2024 17:43:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22A4F6B00FE; Tue, 27 Feb 2024 12:43:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD6D06B0106; Tue, 27 Feb 2024 12:43:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CFBC6B00FA; Tue, 27 Feb 2024 12:43:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 20AF46B00F7 for ; Tue, 27 Feb 2024 12:43:06 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EF4731408BF for ; Tue, 27 Feb 2024 17:43:03 +0000 (UTC) X-FDA: 81838304646.08.E8FD540 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 54B7718001E for ; Tue, 27 Feb 2024 17:43:01 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SXhmA1Ou; spf=none (imf06.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=1709055782; 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=vKMYoOiyUO81OcdzYFKguTw2dj3YSsxMWjG9EzdOdEY=; b=mgEfwdDdBHuxpB0MI0D0PRL01y1I2wy4JSuq16jxq/2CXyDiXmW4zmi8EjmZcKFipC+okW VRcxFhhuWKXitslYpLsLUW6EZJ6SzeJwVjOU6yz89GYuv6gZo2eadW4U6xWHaePV5p+4jN Oo3FMarsixCe8Xg4ySZzP2jpzDx0dD8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709055782; a=rsa-sha256; cv=none; b=8rJUgbDqi9q6p1guKs5zGoyInBvbBaPriKYuzHLrGVxzPV05SnMdIn6yl/UuTueLKdpIOS NCT95NDMuha3rOCIajxn12T/rn3eKzp3XpZJ6a9Y5Xqkk888X2oweN4Wwwpqq8QFE/7l5D vva+lKURxg4QjGh7UejQP/tVHUuTrjE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SXhmA1Ou; spf=none (imf06.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=vKMYoOiyUO81OcdzYFKguTw2dj3YSsxMWjG9EzdOdEY=; b=SXhmA1OudjsbC85VTPejRTCAcV N3FH16PFA8rWEb2kLxok93WxBI4FKxpXRmRdggNkBLNpOUI+ew+lKF5lvlm8dXt7WgvlcHwuPYMYD QON8OiaN3wIlAqv2rpVLp+F9sFYIXS3AML2iBrMnAJIwD5tZHkP+SIJ0ZU+R/7dHkzDHUWYX8Bro1 QEYUEo1vZTUSTR/2FmMNRQhWPSlxkFaNZ33eGHeH2xdxPceCw/zO2I20Bt//Tq36ct/7KMkhpKpwz pZ35xBWRJn4kFHmAu1C515NGkxG+kibV9SF44pizk91ypjl8nTu+75/lMPejJvCIg7vYPFaqx9RKW bhd351eg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf1Tn-00000002ysT-41wl; Tue, 27 Feb 2024 17:43:00 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Ryan Roberts , David Hildenbrand Subject: [PATCH v3 18/18] mm: Convert free_swap_cache() to take a folio Date: Tue, 27 Feb 2024 17:42:52 +0000 Message-ID: <20240227174254.710559-19-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227174254.710559-1-willy@infradead.org> References: <20240227174254.710559-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 54B7718001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: czq8p79d5otzsjyf6wgu1izwsnxhf6n7 X-HE-Tag: 1709055781-116276 X-HE-Meta: U2FsdGVkX18nfuMStO0oOeM0hhnJFByOv73eVdJzvnaeboVQSJk369rC9LU/hK+SlBuTHvvlyBvAsFivoNd7RKBJ/YRApddysnItKPDiVlQB5UMx7AYTg7fNdGCsHk4yI4WXkB93PldBu3YnVYA2mGjXiXduUd3YIY23ietGfSoHh/J+oB5QksUBc7MG4f+BgGx5LqczABl7/ljg15Fr442ClPONdX6ZYEVFx0AdO8UN09BWu8WIIATqTXQuEjhvyStwSvBVRlCyC32/N3ZZbdTDb+igPrhbmx7giRtllZb+ZAF1NjJm4x/mIRy8y2CglBJhcZty0q+7gn7138jwYn8BU3N5L6dDH5Jp537vzSiCUE+MCZ6Fy5gUMZMSEHkrW78caBI58//V93yZ8qo4nV1jQdb1JA+dte91ujBAK+ykO9YxfCSrYCN9ZN0EFHCQ5vbhg6ZI/zSp26ho/saxiMFj+iJEfzxwoZ/J5gCY8ErzTll1g0+FVCbdSB687a0ah3UvwB2C83kuoKOQ6bfPHQ/rYyND2vv+yLeduefkoFk6O++2QoI4blkWdfLiOgM8DnZyXmCNZ5+Y+qXB2hH7XS3/NV/XzdDRxSvbrjHoplfdEhpmcDHQ+SDBsIhgYTSntTdegR/iS6Gd5BeTuLvE3+6IH581cWnwXp4pKupNumbOD+7G6iMZz3W/IHvBLW0keOEeYJComM2za8c6529cz+VpZSF5sCBMHiEIsxHHIFDv4BYLuEYdgc2/8Ff+KueJRbcdYczCfZgXW30LvOcZ6zl2KG6WeYpG3vHfvelP2Ywzuls1ahoHWBK4HWbPn4j5tRyWAjmo0toa5rPRz4TxKpxvUH+TyJy+dC6HQghdvYQafyWj1s7U7l1fWN0pzmxOpjqqjudUPZe59eImeU1CrdtvhfE8PTJz 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 a4b9460d6ca5..f2bddabae199 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3452,7 +3452,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 2a73d3bc5d48..b194dcf49f01 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); } /* @@ -319,7 +319,7 @@ void free_pages_and_swap_cache(struct encoded_page **pages, int nr) 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); refs[folios.nr] = 1; if (unlikely(encoded_page_flags(pages[i]) & ENCODED_PAGE_BIT_NR_PAGES_NEXT))