Skip to contentSkip to conversation

mm/migrate: correct thp migration stats.

PATCH Superseded Zi Yan 3 participants 3 messages Sep 17, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zi Yan

author
#0 lore raw

PATCH 1/1 mm/migrate: correct thp migration stats.

From: Zi Yan <[email protected]>

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.

Fixes 1a5bae25e3cf ("mm/vmstat: add events for THP migration without split")
Cc Daniel Jordan <[email protected]>
Cc Anshuman Khandual <[email protected]>
---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
index 941b89383cf3..d1ad964165e5 100644
@@ -1445,7 +1445,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();
 
Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Zi Yan

From: Zi Yan <[email protected]>

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.

Yeah, shoot.

Quoted 2 lines
Fixes 1a5bae25e3cf ("mm/vmstat: add events for THP migration without split")

If you wanted, you could also do this.

mm/migrate.c +2 -3
index d1ad964165e5..6bc9559afc70 100644
@@ -1471,7 +1471,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);
@@ -1480,8 +1480,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;
reviewer
#2 lore raw
Quoted 7 lines · Daniel Jordan
Quoted 5 lines · Zi Yan

From: Zi Yan <[email protected]>

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.

Quoted 6 lines

Yeah, shoot.

Quoted 2 lines
Fixes 1a5bae25e3cf ("mm/vmstat: add events for THP migration without split")

Thanks.

Quoted 17 lines

If you wanted, you could also do this.

mm/migrate.c +1 -1
index d1ad964165e5..6bc9559afc70 100644
@@ -1471,7 +1471,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);

mm/migrate.c int migrate_pages(struct list_head *from, new_page_t get_new_page, · line 1486

Quoted 9 lines
mm/migrate.c +1 -2
@@ -1480,8 +1480,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;

Yeah, makes sense to me. Let me send V2 to include this.

—
Best Regards,
Yan Zi