[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240320074049.4130552-4-alexs@kernel.org>
Date: Wed, 20 Mar 2024 15:40:39 +0800
From: alexs@...nel.org
To: Izik Eidus <izik.eidus@...ellosystems.com>,
Matthew Wilcox <willy@...radead.org>,
Andrea Arcangeli <aarcange@...hat.com>,
Hugh Dickins <hughd@...gle.com>,
Chris Wright <chrisw@...s-sol.org>,
kasong@...cent.com,
Andrew Morton <akpm@...ux-foundation.org>,
linux-mm@...ck.org (open list:MEMORY MANAGEMENT),
linux-kernel@...r.kernel.org (open list)
Cc: linux-kernel@...r.kernel.org,
"Alex Shi (tencent)" <alexs@...nel.org>
Subject: [PATCH 03/11] mm/ksm: use a folio in remove_stable_node
From: "Alex Shi (tencent)" <alexs@...nel.org>
pages in stable tree are all single normal page, use folios could save
3 calls to compound_head().
Signed-off-by: Alex Shi (tencent) <alexs@...nel.org>
Cc: Izik Eidus <izik.eidus@...ellosystems.com>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Andrea Arcangeli <aarcange@...hat.com>
Cc: Hugh Dickins <hughd@...gle.com>
Cc: Chris Wright <chrisw@...s-sol.org>
---
mm/ksm.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c
index 922e33500875..9ea9b5ac44b4 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1107,11 +1107,11 @@ static inline void set_page_stable_node(struct page *page,
*/
static int remove_stable_node(struct ksm_stable_node *stable_node)
{
- struct page *page;
+ struct folio *folio;
int err;
- page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK);
- if (!page) {
+ folio = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK);
+ if (!folio) {
/*
* get_ksm_page did remove_node_from_stable_tree itself.
*/
@@ -1124,22 +1124,22 @@ static int remove_stable_node(struct ksm_stable_node *stable_node)
* merge_across_nodes/max_page_sharing be switched.
*/
err = -EBUSY;
- if (!page_mapped(page)) {
+ if (!folio_mapped(folio)) {
/*
* The stable node did not yet appear stale to get_ksm_page(),
- * since that allows for an unmapped ksm page to be recognized
+ * since that allows for an unmapped ksm folio to be recognized
* right up until it is freed; but the node is safe to remove.
- * This page might be in an LRU cache waiting to be freed,
+ * This folio might be in an LRU cache waiting to be freed,
* or it might be PageSwapCache (perhaps under writeback),
* or it might have been removed from swapcache a moment ago.
*/
- set_page_stable_node(page, NULL);
+ set_page_stable_node(&folio->page, NULL);
remove_node_from_stable_tree(stable_node);
err = 0;
}
- unlock_page(page);
- put_page(page);
+ folio_unlock(folio);
+ folio_put(folio);
return err;
}
--
2.43.0
Powered by blists - more mailing lists