linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Subject: [PATCH 22/22] mm/swap: Convert __delete_from_swap_cache() to a folio
Date: Fri, 17 Jun 2022 18:50:20 +0100	[thread overview]
Message-ID: <20220617175020.717127-23-willy@infradead.org> (raw)
In-Reply-To: <20220617175020.717127-1-willy@infradead.org>

All callers now have a folio, so convert the entire function to operate
on folios.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/swap.h       |  4 ++--
 mm/swap_state.c | 25 +++++++++++++------------
 mm/vmscan.c     |  2 +-
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/mm/swap.h b/mm/swap.h
index 3684f7f4eac9..fa0816af4712 100644
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -36,7 +36,7 @@ bool add_to_swap(struct folio *folio);
 void *get_shadow_from_swap_cache(swp_entry_t entry);
 int add_to_swap_cache(struct page *page, swp_entry_t entry,
 		      gfp_t gfp, void **shadowp);
-void __delete_from_swap_cache(struct page *page,
+void __delete_from_swap_cache(struct folio *folio,
 			      swp_entry_t entry, void *shadow);
 void delete_from_swap_cache(struct folio *folio);
 void clear_shadow_from_swap_cache(int type, unsigned long begin,
@@ -135,7 +135,7 @@ static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
 	return -1;
 }
 
-static inline void __delete_from_swap_cache(struct page *page,
+static inline void __delete_from_swap_cache(struct folio *folio,
 					swp_entry_t entry, void *shadow)
 {
 }
diff --git a/mm/swap_state.c b/mm/swap_state.c
index b9464542c064..e166051566f4 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -133,31 +133,32 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry,
 }
 
 /*
- * This must be called only on pages that have
+ * This must be called only on folios that have
  * been verified to be in the swap cache.
  */
-void __delete_from_swap_cache(struct page *page,
+void __delete_from_swap_cache(struct folio *folio,
 			swp_entry_t entry, void *shadow)
 {
 	struct address_space *address_space = swap_address_space(entry);
-	int i, nr = thp_nr_pages(page);
+	int i;
+	long nr = folio_nr_pages(folio);
 	pgoff_t idx = swp_offset(entry);
 	XA_STATE(xas, &address_space->i_pages, idx);
 
-	VM_BUG_ON_PAGE(!PageLocked(page), page);
-	VM_BUG_ON_PAGE(!PageSwapCache(page), page);
-	VM_BUG_ON_PAGE(PageWriteback(page), page);
+	VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
+	VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio);
+	VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio);
 
 	for (i = 0; i < nr; i++) {
 		void *entry = xas_store(&xas, shadow);
-		VM_BUG_ON_PAGE(entry != page, entry);
-		set_page_private(page + i, 0);
+		VM_BUG_ON_FOLIO(entry != folio, folio);
+		set_page_private(folio_page(folio, i), 0);
 		xas_next(&xas);
 	}
-	ClearPageSwapCache(page);
+	folio_clear_swapcache(folio);
 	address_space->nrpages -= nr;
-	__mod_node_page_state(page_pgdat(page), NR_FILE_PAGES, -nr);
-	__mod_lruvec_page_state(page, NR_SWAPCACHE, -nr);
+	__node_stat_mod_folio(folio, NR_FILE_PAGES, -nr);
+	__lruvec_stat_mod_folio(folio, NR_SWAPCACHE, -nr);
 }
 
 /**
@@ -233,7 +234,7 @@ void delete_from_swap_cache(struct folio *folio)
 	struct address_space *address_space = swap_address_space(entry);
 
 	xa_lock_irq(&address_space->i_pages);
-	__delete_from_swap_cache(&folio->page, entry, NULL);
+	__delete_from_swap_cache(folio, entry, NULL);
 	xa_unlock_irq(&address_space->i_pages);
 
 	put_swap_page(&folio->page, entry);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 1256d6b51b67..6a5c34dee00a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1329,7 +1329,7 @@ static int __remove_mapping(struct address_space *mapping, struct folio *folio,
 		mem_cgroup_swapout(folio, swap);
 		if (reclaimed && !mapping_exiting(mapping))
 			shadow = workingset_eviction(folio, target_memcg);
-		__delete_from_swap_cache(&folio->page, swap, shadow);
+		__delete_from_swap_cache(folio, swap, shadow);
 		xa_unlock_irq(&mapping->i_pages);
 		put_swap_page(&folio->page, swap);
 	} else {
-- 
2.35.1



      parent reply	other threads:[~2022-06-17 17:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 17:49 [PATCH 00/22] Convert the swap code to be more folio-based Matthew Wilcox (Oracle)
2022-06-17 17:49 ` [PATCH 01/22] mm: Add folios_put() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 02/22] mm/swap: Add folio_batch_move_lru() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 03/22] mm/swap: Make __pagevec_lru_add static Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 04/22] mm/swap: Convert lru_add to a folio_batch Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 05/22] mm/swap: Convert lru_deactivate_file " Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 06/22] mm/swap: Convert lru_deactivate " Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 07/22] mm/swap: Convert lru_lazyfree " Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 08/22] mm/swap: Convert activate_page " Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 09/22] mm/swap: Rename lru_pvecs to cpu_fbatches Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 10/22] mm/swap: Pull the CPU conditional out of __lru_add_drain_all() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 11/22] mm/swap: Optimise lru_add_drain_cpu() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 12/22] mm/swap: Convert try_to_free_swap to use a folio Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 13/22] mm/swap: Convert release_pages to use a folio internally Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 14/22] mm/swap: Convert put_pages_list to use folios Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 15/22] mm/swap: Convert __put_page() to __folio_put() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 16/22] mm/swap: Convert __put_single_page() to __folio_put_small() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 17/22] mm/swap: Convert __put_compound_page() to __folio_put_large() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 18/22] mm/swap: Convert __page_cache_release() to use a folio Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 19/22] mm: Convert destroy_compound_page() to destroy_large_folio() Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 20/22] mm: Convert page_swap_flags to folio_swap_flags Matthew Wilcox (Oracle)
2022-06-17 17:50 ` [PATCH 21/22] mm/swap: Convert delete_from_swap_cache() to take a folio Matthew Wilcox (Oracle)
2022-06-17 17:50 ` Matthew Wilcox (Oracle) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220617175020.717127-23-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox