From: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Subject: [PATCH mm-unstable v2 4/6] mm/mempolicy: Convert queue_pages_hugetlb() to queue_folios_hugetlb()
Date: Mon, 23 Jan 2023 17:22:08 -0800 [thread overview]
Message-ID: <20230124012210.13963-5-vishal.moola@gmail.com> (raw)
In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com>
This change is in preparation for the conversion of
queue_pages_required() to queue_folio_required() and migrate_page_add()
to migrate_folio_add().
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
mm/mempolicy.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index ae9d16124f45..ea8cac447e04 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -558,7 +558,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr,
return addr != end ? -EIO : 0;
}
-static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
+static int queue_folios_hugetlb(pte_t *pte, unsigned long hmask,
unsigned long addr, unsigned long end,
struct mm_walk *walk)
{
@@ -566,7 +566,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
#ifdef CONFIG_HUGETLB_PAGE
struct queue_pages *qp = walk->private;
unsigned long flags = (qp->flags & MPOL_MF_VALID);
- struct page *page;
+ struct folio *folio;
spinlock_t *ptl;
pte_t entry;
@@ -574,13 +574,13 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
entry = huge_ptep_get(pte);
if (!pte_present(entry))
goto unlock;
- page = pte_page(entry);
- if (!queue_pages_required(page, qp))
+ folio = pfn_folio(pte_pfn(entry));
+ if (!queue_pages_required(&folio->page, qp))
goto unlock;
if (flags == MPOL_MF_STRICT) {
/*
- * STRICT alone means only detecting misplaced page and no
+ * STRICT alone means only detecting misplaced folio and no
* need to further check other vma.
*/
ret = -EIO;
@@ -591,20 +591,27 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
/*
* Must be STRICT with MOVE*, otherwise .test_walk() have
* stopped walking current vma.
- * Detecting misplaced page but allow migrating pages which
+ * Detecting misplaced folio but allow migrating folios which
* have been queued.
*/
ret = 1;
goto unlock;
}
- /* With MPOL_MF_MOVE, we migrate only unshared hugepage. */
+ /*
+ * With MPOL_MF_MOVE, we try to migrate only unshared folios. If it
+ * is shared it is likely not worth migrating.
+ *
+ * To check if the folio is shared, ideally we want to make sure
+ * every page is mapped to the same process. Doing that is very
+ * expensive, so check the estimated mapcount of the folio instead.
+ */
if (flags & (MPOL_MF_MOVE_ALL) ||
- (flags & MPOL_MF_MOVE && page_mapcount(page) == 1)) {
- if (isolate_hugetlb(page_folio(page), qp->pagelist) &&
+ (flags & MPOL_MF_MOVE && folio_estimated_mapcount(folio) == 1)) {
+ if (isolate_hugetlb(folio, qp->pagelist) &&
(flags & MPOL_MF_STRICT))
/*
- * Failed to isolate page but allow migrating pages
+ * Failed to isolate folio but allow migrating folios
* which have been queued.
*/
ret = 1;
@@ -702,7 +709,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
}
static const struct mm_walk_ops queue_pages_walk_ops = {
- .hugetlb_entry = queue_pages_hugetlb,
+ .hugetlb_entry = queue_folios_hugetlb,
.pmd_entry = queue_folios_pte_range,
.test_walk = queue_pages_test_walk,
};
--
2.38.1
next prev parent reply other threads:[~2023-01-24 1:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 1:22 [PATCH mm-unstable v2 0/6] Convert various mempolicy.c functions Vishal Moola (Oracle)
2023-01-24 1:22 ` [PATCH mm-unstable v2 1/6] mm: Add folio_estimated_mapcount() Vishal Moola (Oracle)
2023-01-24 3:23 ` kernel test robot
2023-01-25 10:20 ` David Hildenbrand
2023-01-25 10:24 ` David Hildenbrand
2023-01-25 21:29 ` David Hildenbrand
2023-01-25 22:09 ` Vishal Moola
2023-01-26 8:37 ` David Hildenbrand
2023-01-28 0:48 ` Jane Chu
2023-01-30 9:34 ` David Hildenbrand
2023-01-28 13:20 ` Yin, Fengwei
2023-01-24 1:22 ` [PATCH mm-unstable v2 2/6] mm/mempolicy: Convert queue_pages_pmd() to queue_folios_pmd() Vishal Moola (Oracle)
2023-01-24 1:22 ` [PATCH mm-unstable v2 3/6] mm/mempolicy: Convert queue_pages_pte_range() to queue_folios_pte_range() Vishal Moola (Oracle)
2023-01-24 1:22 ` Vishal Moola (Oracle) [this message]
2023-01-24 1:22 ` [PATCH mm-unstable v2 5/6] mm/mempolicy: Convert queue_pages_required() to queue_folio_required() Vishal Moola (Oracle)
2023-01-24 1:22 ` [PATCH mm-unstable v2 6/6] mm/mempolicy: Convert migrate_page_add() to migrate_folio_add() Vishal Moola (Oracle)
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=20230124012210.13963-5-vishal.moola@gmail.com \
--to=vishal.moola@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@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).