From: Zi Yan <ziy(a)nvidia.com>
ANBZ: #80
commit 6c5c7b9f3352728af490183f71d350bb658ffb75 upstream
PageTransHuge returns true for both thp and hugetlb, so thp stats was
counting both thp and hugetlb migrations. Exclude hugetlb migration by
setting is_thp variable right.
Clean up thp handling code too when we are there.
Fixes: 1a5bae25e3cf ("mm/vmstat: add events for THP migration without split")
Signed-off-by: Zi Yan <ziy(a)nvidia.com>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Reviewed-by: Daniel Jordan <daniel.m.jordan(a)oracle.com>
Cc: Anshuman Khandual <anshuman.khandual(a)arm.com>
Link:
https://lkml.kernel.org/r/20200917210413.1462975-1-zi.yan@sent.com
Signed-off-by: Linus Torvalds <torvalds(a)linux-foundation.org>
Signed-off-by: Baolin Wang <baolin.wang(a)linux.alibaba.com>
---
mm/migrate.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 9cbf2ec..1ce6cf4 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1489,7 +1489,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
* Capture required information that might get lost
* during migration.
*/
- is_thp = PageTransHuge(page);
+ is_thp = PageTransHuge(page) && !PageHuge(page);;
nr_subpages = hpage_nr_pages(page);
cond_resched();
@@ -1515,7 +1515,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
* we encounter them after the rest of the list
* is processed.
*/
- if (PageTransHuge(page) && !PageHuge(page)) {
+ if (is_thp) {
lock_page(page);
rc = split_huge_page_to_list(page, from);
unlock_page(page);
@@ -1524,8 +1524,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
nr_thp_split++;
goto retry;
}
- }
- if (is_thp) {
+
nr_thp_failed++;
nr_failed += nr_subpages;
goto out;
--
1.8.3.1