Skip to content

Commit

Permalink
mm/migrate: correct thp migration stats
Browse files Browse the repository at this point in the history
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: 1a5bae2 ("mm/vmstat: add events for THP migration without split")
Signed-off-by: Zi Yan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Daniel Jordan <[email protected]>
Cc: Anshuman Khandual <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
x-y-z authored and torvalds committed Sep 26, 2020
1 parent d3f7b1b commit 6c5c7b9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,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 = thp_nr_pages(page);
cond_resched();

Expand All @@ -1472,7 +1472,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);
Expand All @@ -1481,8 +1481,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;
Expand Down

0 comments on commit 6c5c7b9

Please sign in to comment.