From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: [PATCH 08/10] mm: Turn deactivate_file_page() into deactivate_file_folio()
Date: Mon, 14 Feb 2022 20:00:15 +0000 [thread overview]
Message-ID: <20220214200017.3150590-9-willy@infradead.org> (raw)
In-Reply-To: <20220214200017.3150590-1-willy@infradead.org>
This function has one caller which already has a reference to the
page, so we don't need to use get_page_unless_zero(). Also move the
prototype to mm/internal.h.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/swap.h | 1 -
mm/internal.h | 1 +
mm/swap.c | 33 ++++++++++++++++-----------------
mm/truncate.c | 2 +-
4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 304f174b4d31..064e60e9f63f 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -372,7 +372,6 @@ extern void lru_add_drain(void);
extern void lru_add_drain_cpu(int cpu);
extern void lru_add_drain_cpu_zone(struct zone *zone);
extern void lru_add_drain_all(void);
-extern void deactivate_file_page(struct page *page);
extern void deactivate_page(struct page *page);
extern void mark_page_lazyfree(struct page *page);
extern void swap_setup(void);
diff --git a/mm/internal.h b/mm/internal.h
index 927a17d58b85..d886b87b1294 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -66,6 +66,7 @@ static inline void wake_throttle_isolated(pg_data_t *pgdat)
vm_fault_t do_swap_page(struct vm_fault *vmf);
void folio_rotate_reclaimable(struct folio *folio);
bool __folio_end_writeback(struct folio *folio);
+void deactivate_file_folio(struct folio *folio);
void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
unsigned long floor, unsigned long ceiling);
diff --git a/mm/swap.c b/mm/swap.c
index bcf3ac288b56..745915127b1f 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -639,32 +639,31 @@ void lru_add_drain_cpu(int cpu)
}
/**
- * deactivate_file_page - forcefully deactivate a file page
- * @page: page to deactivate
+ * deactivate_file_folio() - Forcefully deactivate a file folio.
+ * @folio: Folio to deactivate.
*
- * This function hints the VM that @page is a good reclaim candidate,
- * for example if its invalidation fails due to the page being dirty
+ * This function hints to the VM that @folio is a good reclaim candidate,
+ * for example if its invalidation fails due to the folio being dirty
* or under writeback.
*/
-void deactivate_file_page(struct page *page)
+void deactivate_file_folio(struct folio *folio)
{
+ struct pagevec *pvec;
+
/*
- * In a workload with many unevictable page such as mprotect,
- * unevictable page deactivation for accelerating reclaim is pointless.
+ * In a workload with many unevictable pages such as mprotect,
+ * unevictable folio deactivation for accelerating reclaim is pointless.
*/
- if (PageUnevictable(page))
+ if (folio_test_unevictable(folio))
return;
- if (likely(get_page_unless_zero(page))) {
- struct pagevec *pvec;
-
- local_lock(&lru_pvecs.lock);
- pvec = this_cpu_ptr(&lru_pvecs.lru_deactivate_file);
+ folio_get(folio);
+ local_lock(&lru_pvecs.lock);
+ pvec = this_cpu_ptr(&lru_pvecs.lru_deactivate_file);
- if (pagevec_add_and_need_flush(pvec, page))
- pagevec_lru_move_fn(pvec, lru_deactivate_file_fn);
- local_unlock(&lru_pvecs.lock);
- }
+ if (pagevec_add_and_need_flush(pvec, &folio->page))
+ pagevec_lru_move_fn(pvec, lru_deactivate_file_fn);
+ local_unlock(&lru_pvecs.lock);
}
/*
diff --git a/mm/truncate.c b/mm/truncate.c
index 567557c36d45..14486e75ec28 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -525,7 +525,7 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
* of interest and try to speed up its reclaim.
*/
if (!ret) {
- deactivate_file_page(&folio->page);
+ deactivate_file_folio(folio);
/* It is likely on the pagevec of a remote CPU */
if (nr_pagevec)
(*nr_pagevec)++;
--
2.34.1
next prev parent reply other threads:[~2022-02-14 20:21 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 20:00 [PATCH 00/10] Various fixes around invalidate_page() Matthew Wilcox (Oracle)
2022-02-14 20:00 ` [PATCH 01/10] splice: Use a folio in page_cache_pipe_buf_try_steal() Matthew Wilcox (Oracle)
2022-02-15 7:15 ` Christoph Hellwig
2022-02-15 8:32 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 02/10] mm/truncate: Inline invalidate_complete_page() into its one caller Matthew Wilcox (Oracle)
2022-02-14 23:09 ` John Hubbard
2022-02-14 23:32 ` Matthew Wilcox
2022-02-14 23:51 ` John Hubbard
2022-02-15 7:17 ` Christoph Hellwig
2022-02-15 7:45 ` Miaohe Lin
2022-02-15 20:09 ` Matthew Wilcox
2022-02-16 2:36 ` Miaohe Lin
2022-02-16 2:45 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 03/10] mm/truncate: Convert invalidate_inode_page() to use a folio Matthew Wilcox (Oracle)
2022-02-15 7:18 ` Christoph Hellwig
2022-02-15 8:32 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 04/10] mm/truncate: Replace page_mapped() call in invalidate_inode_page() Matthew Wilcox (Oracle)
2022-02-15 7:19 ` Christoph Hellwig
2022-02-15 20:12 ` Matthew Wilcox
2022-02-15 8:32 ` Miaohe Lin
2022-02-25 1:31 ` Matthew Wilcox
2022-02-25 3:27 ` Matthew Wilcox
2022-02-14 20:00 ` [PATCH 05/10] mm: Convert remove_mapping() to take a folio Matthew Wilcox (Oracle)
2022-02-15 7:21 ` Christoph Hellwig
2022-02-15 8:33 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 06/10] mm/truncate: Split invalidate_inode_page() into mapping_shrink_folio() Matthew Wilcox (Oracle)
2022-02-15 7:23 ` Christoph Hellwig
2022-02-15 9:37 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 07/10] mm/truncate: Convert __invalidate_mapping_pages() to use a folio Matthew Wilcox (Oracle)
2022-02-15 7:24 ` Christoph Hellwig
2022-02-15 9:37 ` Miaohe Lin
2022-02-14 20:00 ` Matthew Wilcox (Oracle) [this message]
2022-02-15 7:25 ` [PATCH 08/10] mm: Turn deactivate_file_page() into deactivate_file_folio() Christoph Hellwig
2022-02-15 8:26 ` Miaohe Lin
2022-02-15 20:33 ` Matthew Wilcox
2022-02-16 2:45 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 09/10] mm/truncate: Combine invalidate_mapping_pagevec() and __invalidate_mapping_pages() Matthew Wilcox (Oracle)
2022-02-15 7:26 ` Christoph Hellwig
2022-02-15 9:37 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 10/10] fs: Move many prototypes to pagemap.h Matthew Wilcox (Oracle)
2022-02-15 7:27 ` Christoph Hellwig
2022-02-15 9:38 ` Miaohe Lin
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=20220214200017.3150590-9-willy@infradead.org \
--to=willy@infradead.org \
--cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).