From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: akpm@linux-foundation.org
Cc: mgorman@techsingularity.net, shy828301@gmail.com,
david@redhat.com, ying.huang@intel.com,
baolin.wang@linux.alibaba.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/4] mm: migrate: change to return the number of pages migrated successfully
Date: Tue, 22 Aug 2023 08:53:52 +0800 [thread overview]
Message-ID: <9688ba40be86d7d0af0961e74d2a182ce65f5f8c.1692665449.git.baolin.wang@linux.alibaba.com> (raw)
In-Reply-To: <cover.1692665449.git.baolin.wang@linux.alibaba.com>
Change the migrate_misplaced_page() to return the number of pages migrated
successfully, which is used to calculate how many pages are failed to
migrate for batch migration. For the compound page's NUMA balancing support,
it is possible that partial pages were successfully migrated, so it is
necessary to return the number of pages that were successfully migrated from
migrate_misplaced_page().
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
mm/huge_memory.c | 9 +++++----
mm/memory.c | 4 +++-
mm/migrate.c | 5 +----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 4401a3493544..951f73d6b5bf 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1494,10 +1494,11 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
int page_nid = NUMA_NO_NODE;
int target_nid, last_cpupid = (-1 & LAST_CPUPID_MASK);
- bool migrated = false, writable = false;
+ bool writable = false;
int flags = 0;
pg_data_t *pgdat;
LIST_HEAD(migratepages);
+ int nr_successed;
vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
if (unlikely(!pmd_same(oldpmd, *vmf->pmd))) {
@@ -1554,9 +1555,9 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
}
list_add(&page->lru, &migratepages);
- migrated = migrate_misplaced_page(&migratepages, vma,
- page_nid, target_nid);
- if (migrated) {
+ nr_successed = migrate_misplaced_page(&migratepages, vma,
+ page_nid, target_nid);
+ if (nr_successed) {
flags |= TNF_MIGRATED;
page_nid = target_nid;
} else {
diff --git a/mm/memory.c b/mm/memory.c
index 9e417e8dd5d5..2773cd804ee9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4771,6 +4771,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
int flags = 0;
pg_data_t *pgdat;
LIST_HEAD(migratepages);
+ int nr_succeeded;
/*
* The "pte" at this point cannot be used safely without
@@ -4854,7 +4855,8 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
list_add(&page->lru, &migratepages);
/* Migrate to the requested node */
- if (migrate_misplaced_page(&migratepages, vma, page_nid, target_nid)) {
+ nr_succeeded = migrate_misplaced_page(&migratepages, vma, page_nid, target_nid);
+ if (nr_succeeded) {
page_nid = target_nid;
flags |= TNF_MIGRATED;
} else {
diff --git a/mm/migrate.c b/mm/migrate.c
index fae7224b8e64..5435cfb225ab 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2523,7 +2523,6 @@ int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct
int source_nid, int target_nid)
{
pg_data_t *pgdat = NODE_DATA(target_nid);
- int migrated = 1;
int nr_remaining;
unsigned int nr_succeeded;
@@ -2533,8 +2532,6 @@ int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct
if (nr_remaining) {
if (!list_empty(migratepages))
putback_movable_pages(migratepages);
-
- migrated = 0;
}
if (nr_succeeded) {
count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded);
@@ -2543,7 +2540,7 @@ int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct
nr_succeeded);
}
BUG_ON(!list_empty(migratepages));
- return migrated;
+ return nr_succeeded;
}
#endif /* CONFIG_NUMA_BALANCING */
#endif /* CONFIG_NUMA */
--
2.39.3
next prev parent reply other threads:[~2023-08-22 0:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 0:53 [PATCH v2 0/4] Extend migrate_misplaced_page() to support batch migration Baolin Wang
2023-08-22 0:53 ` [PATCH v2 1/4] mm: migrate: factor out migration validation into numa_page_can_migrate() Baolin Wang
2023-08-22 0:53 ` [PATCH v2 2/4] mm: migrate: move the numamigrate_isolate_page() into do_numa_page() Baolin Wang
2023-08-22 9:02 ` Bharata B Rao
2023-08-24 3:14 ` Baolin Wang
2023-08-22 0:53 ` [PATCH v2 3/4] mm: migrate: change migrate_misplaced_page() to support multiple pages migration Baolin Wang
2023-08-22 0:53 ` Baolin Wang [this message]
2023-08-22 2:47 ` [PATCH v2 0/4] Extend migrate_misplaced_page() to support batch migration Huang, Ying
2023-08-24 3:13 ` Baolin Wang
2023-08-24 4:51 ` Huang, Ying
2023-08-24 6:26 ` Baolin Wang
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=9688ba40be86d7d0af0961e74d2a182ce65f5f8c.1692665449.git.baolin.wang@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=shy828301@gmail.com \
--cc=ying.huang@intel.com \
/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