Skip to content

Commit c640825

Browse files
x-y-zakpm00
authored andcommitted
mm/migrate: make migrate_pages_batch() stats consistent
As Ying pointed out in [1], stats->nr_thp_failed needs to be updated to avoid stats inconsistency between MIGRATE_SYNC and MIGRATE_ASYNC when calling migrate_pages_batch(). Because if not, when migrate_pages_batch() is called via migrate_pages(MIGRATE_ASYNC), nr_thp_failed will not be increased and when migrate_pages_batch() is called via migrate_pages(MIGRATE_SYNC*), nr_thp_failed will be increase in migrate_pages_sync() by stats->nr_thp_failed += astats.nr_thp_split. [1] https://lore.kernel.org/linux-mm/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 7262f20 ("mm/migrate: split source folio if it is on deferred split list") Signed-off-by: Zi Yan <[email protected]> Suggested-by: "Huang, Ying" <[email protected]> Reviewed-by: "Huang, Ying" <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Yang Shi <[email protected]> Cc: Yin Fengwei <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f3228a2 commit c640825

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mm/migrate.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,10 @@ static int migrate_pages_batch(struct list_head *from,
16591659
* migrate_pages() may report success with (split but
16601660
* unmigrated) pages still on its fromlist; whereas it
16611661
* always reports success when its fromlist is empty.
1662+
* stats->nr_thp_failed should be increased too,
1663+
* otherwise stats inconsistency will happen when
1664+
* migrate_pages_batch is called via migrate_pages()
1665+
* with MIGRATE_SYNC and MIGRATE_ASYNC.
16621666
*
16631667
* Only check it without removing it from the list.
16641668
* Since the folio can be on deferred_split_scan()
@@ -1675,6 +1679,7 @@ static int migrate_pages_batch(struct list_head *from,
16751679
!list_empty(&folio->_deferred_list)) {
16761680
if (try_split_folio(folio, split_folios) == 0) {
16771681
nr_failed++;
1682+
stats->nr_thp_failed += is_thp;
16781683
stats->nr_thp_split += is_thp;
16791684
stats->nr_split++;
16801685
continue;

0 commit comments

Comments
 (0)