From: alexs@kernel.org
To: Matthew Wilcox <willy@infradead.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Izik Eidus <izik.eidus@ravellosystems.com>,
david@redhat.com, Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
ryncsn@gmail.com
Cc: "Alex Shi (tencent)" <alexs@kernel.org>,
Hugh Dickins <hughd@google.com>,
Chris Wright <chrisw@sous-sol.org>
Subject: [PATCH v3 11/14] mm/ksm: remove get_ksm_page and related info
Date: Mon, 25 Mar 2024 20:48:58 +0800 [thread overview]
Message-ID: <20240325124904.398913-12-alexs@kernel.org> (raw)
In-Reply-To: <20240325124904.398913-1-alexs@kernel.org>
From: "Alex Shi (tencent)" <alexs@kernel.org>
Now since all caller are changed to ksm_get_folio, let's sync up the
related usages with ksm_get_folio, and remove get_ksm_page.
Signed-off-by: Alex Shi (tencent) <alexs@kernel.org>
Cc: Izik Eidus <izik.eidus@ravellosystems.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Chris Wright <chrisw@sous-sol.org>
---
mm/ksm.c | 34 +++++++++++++---------------------
mm/migrate.c | 2 +-
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c
index e92445f29685..0ad02524e363 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -890,14 +890,14 @@ static void remove_node_from_stable_tree(struct ksm_stable_node *stable_node)
free_stable_node(stable_node);
}
-enum get_ksm_page_flags {
+enum ksm_get_folio_flags {
GET_KSM_PAGE_NOLOCK,
GET_KSM_PAGE_LOCK,
GET_KSM_PAGE_TRYLOCK
};
/*
- * get_ksm_page: checks if the page indicated by the stable node
+ * ksm_get_folio: checks if the page indicated by the stable node
* is still its ksm page, despite having held no reference to it.
* In which case we can trust the content of the page, and it
* returns the gotten page; but if the page has now been zapped,
@@ -916,7 +916,7 @@ enum get_ksm_page_flags {
* is on its way to being freed; but it is an anomaly to bear in mind.
*/
static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node,
- enum get_ksm_page_flags flags)
+ enum ksm_get_folio_flags flags)
{
struct folio *folio;
void *expected_mapping;
@@ -990,14 +990,6 @@ static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node,
return NULL;
}
-static struct page *get_ksm_page(struct ksm_stable_node *stable_node,
- enum get_ksm_page_flags flags)
-{
- struct folio *folio = ksm_get_folio(stable_node, flags);
-
- return &folio->page;
-}
-
/*
* Removing rmap_item from stable or unstable tree.
* This function will clean the information from the stable/unstable tree.
@@ -1127,7 +1119,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node)
folio = ksm_get_folio(stable_node, GET_KSM_PAGE_LOCK);
if (!folio) {
/*
- * get_ksm_page did remove_node_from_stable_tree itself.
+ * ksm_get_folio did remove_node_from_stable_tree itself.
*/
return 0;
}
@@ -1140,7 +1132,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node)
err = -EBUSY;
if (!folio_mapped(folio)) {
/*
- * The stable node did not yet appear stale to get_ksm_page(),
+ * The stable node did not yet appear stale to ksm_get_folio(),
* 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 folio might be in an LRU cache waiting to be freed,
@@ -1657,7 +1649,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup,
* We must walk all stable_node_dup to prune the stale
* stable nodes during lookup.
*
- * get_ksm_page can drop the nodes from the
+ * ksm_get_folio can drop the nodes from the
* stable_node->hlist if they point to freed pages
* (that's why we do a _safe walk). The "dup"
* stable_node parameter itself will be freed from
@@ -1764,7 +1756,7 @@ static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stabl
}
/*
- * Like for get_ksm_page, this function can free the *_stable_node and
+ * Like for ksm_get_folio, this function can free the *_stable_node and
* *_stable_node_dup if the returned tree_page is NULL.
*
* It can also free and overwrite *_stable_node with the found
@@ -1786,7 +1778,7 @@ static void *__stable_node_chain(struct ksm_stable_node **_stable_node_dup,
if (!is_stable_node_chain(stable_node)) {
if (is_page_sharing_candidate(stable_node)) {
*_stable_node_dup = stable_node;
- return get_ksm_page(stable_node, GET_KSM_PAGE_NOLOCK);
+ return ksm_get_folio(stable_node, GET_KSM_PAGE_NOLOCK);
}
/*
* _stable_node_dup set to NULL means the stable_node
@@ -1900,7 +1892,7 @@ static void *stable_tree_search(struct page *page)
if (!tree_folio) {
/*
* If we walked over a stale stable_node,
- * get_ksm_page() will call rb_erase() and it
+ * ksm_get_folio() will call rb_erase() and it
* may rebalance the tree from under us. So
* restart the search from scratch. Returning
* NULL would be safe too, but we'd generate
@@ -2133,7 +2125,7 @@ static struct ksm_stable_node *stable_tree_insert(struct folio *kfolio)
if (!tree_folio) {
/*
* If we walked over a stale stable_node,
- * get_ksm_page() will call rb_erase() and it
+ * ksm_get_folio() will call rb_erase() and it
* may rebalance the tree from under us. So
* restart the search from scratch. Returning
* NULL would be safe too, but we'd generate
@@ -3245,7 +3237,7 @@ void folio_migrate_ksm(struct folio *newfolio, struct folio *folio)
/*
* newfolio->mapping was set in advance; now we need smp_wmb()
* to make sure that the new stable_node->kpfn is visible
- * to get_ksm_page() before it can see that folio->mapping
+ * to ksm_get_folio() before it can see that folio->mapping
* has gone stale (or that folio_test_swapcache has been cleared).
*/
smp_wmb();
@@ -3272,7 +3264,7 @@ static bool stable_node_dup_remove_range(struct ksm_stable_node *stable_node,
if (stable_node->kpfn >= start_pfn &&
stable_node->kpfn < end_pfn) {
/*
- * Don't get_ksm_page, page has already gone:
+ * Don't ksm_get_folio, page has already gone:
* which is why we keep kpfn instead of page*
*/
remove_node_from_stable_tree(stable_node);
@@ -3360,7 +3352,7 @@ static int ksm_memory_callback(struct notifier_block *self,
* Most of the work is done by page migration; but there might
* be a few stable_nodes left over, still pointing to struct
* pages which have been offlined: prune those from the tree,
- * otherwise get_ksm_page() might later try to access a
+ * otherwise ksm_get_folio() might later try to access a
* non-existent struct page.
*/
ksm_check_stable_tree(mn->start_pfn,
diff --git a/mm/migrate.c b/mm/migrate.c
index 73a052a382f1..9f0494fd902c 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -616,7 +616,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
folio_migrate_ksm(newfolio, folio);
/*
* Please do not reorder this without considering how mm/ksm.c's
- * get_ksm_page() depends upon ksm_migrate_page() and PageSwapCache().
+ * ksm_get_folio() depends upon ksm_migrate_page() and PageSwapCache().
*/
if (folio_test_swapcache(folio))
folio_clear_swapcache(folio);
--
2.43.0
next prev parent reply other threads:[~2024-03-25 12:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 12:48 [PATCH v2 00/14] transfer page to folio in KSM alexs
2024-03-25 12:47 ` David Hildenbrand
2024-03-25 12:48 ` [PATCH v3 01/14] mm/ksm: add ksm_get_folio alexs
2024-04-05 7:23 ` David Hildenbrand
2024-03-25 12:48 ` [PATCH v3 02/14] mm/ksm: use folio in remove_rmap_item_from_tree alexs
2024-03-25 12:48 ` [PATCH v3 03/14] mm/ksm: add folio_set_stable_node alexs
2024-03-25 12:48 ` [PATCH v3 04/14] mm/ksm: use folio in remove_stable_node alexs
2024-03-25 12:48 ` [PATCH v3 05/14] mm/ksm: use folio in stable_node_dup alexs
2024-03-25 12:48 ` [PATCH v3 06/14] mm/ksm: use ksm_get_folio in scan_get_next_rmap_item alexs
2024-04-05 7:28 ` David Hildenbrand
2024-03-25 12:48 ` [PATCH v3 07/14] mm/ksm: use folio in write_protect_page alexs
[not found] ` <e16806b0-7c17-4356-8b47-30f624756e85@redhat.com>
2024-04-08 6:58 ` Alex Shi
2024-03-25 12:48 ` [PATCH v3 08/14] mm/ksm: Convert chain series funcs to use folio alexs
2024-04-05 7:36 ` David Hildenbrand
2024-03-25 12:48 ` [PATCH v3 09/14] mm/ksm: Convert stable_tree_insert " alexs
2024-03-25 12:48 ` [PATCH v3 10/14] mm/ksm: Convert stable_tree_search " alexs
2024-03-25 12:48 ` alexs [this message]
[not found] ` <15080b4f-ac9f-4f5f-9a27-d1773d015fdc@redhat.com>
2024-04-08 6:59 ` [PATCH v3 11/14] mm/ksm: remove get_ksm_page and related info Alex Shi
2024-03-25 12:48 ` [PATCH v3 12/14] mm/ksm: return folio for chain series funcs alexs
2024-03-25 12:49 ` [PATCH v3 13/14] mm/ksm: use folio_set_stable_node in try_to_merge_one_page alexs
2024-04-05 9:06 ` David Hildenbrand
2024-03-25 12:49 ` [PATCH v3 14/14] mm/ksm: remove set_page_stable_node alexs
2024-04-05 7:32 ` David Hildenbrand
2024-04-08 7:00 ` Alex Shi
2024-04-05 9:07 ` David Hildenbrand
2024-04-08 7:01 ` Alex Shi
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=20240325124904.398913-12-alexs@kernel.org \
--to=alexs@kernel.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chrisw@sous-sol.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=izik.eidus@ravellosystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryncsn@gmail.com \
--cc=willy@infradead.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).