From: Huang Ying <ying.huang@xxxxxxxxx> commit 851ae6424697d1c4f085cb878c88168923ebcad1 upstream. In commit fd4a7ac32918 ("mm: migrate: try again if THP split is failed due to page refcnt"), if the THP splitting fails due to page reference count, we will retry to improve migration successful rate. But the failed splitting is counted as migration failure and migration retry, which will cause duplicated failure counting. So, in this patch, this is fixed via undoing the failure counting if we decide to retry. The patch is tested via failure injection. Link: https://lkml.kernel.org/r/20230416235929.1040194-1-ying.huang@xxxxxxxxx Fixes: fd4a7ac32918 ("mm: migrate: try again if THP split is failed due to page refcnt") Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx> Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Yang Shi <shy828301@xxxxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1700,6 +1700,9 @@ split_folio_migration: large_retry++; thp_retry += is_thp; nr_retry_pages += nr_pages; + /* Undo duplicated failure counting. */ + nr_large_failed--; + stats->nr_thp_failed -= is_thp; break; } } Patches currently in stable-queue which might be from ying.huang@xxxxxxxxx are queue-6.1/migrate-convert-unmap_and_move-to-use-folios.patch queue-6.1/mm-migrate-try-again-if-thp-split-is-failed-due-to-p.patch queue-6.1/migrate-convert-migrate_pages-to-use-folios.patch queue-6.1/migrate_pages-separate-hugetlb-folios-migration.patch queue-6.1/vmscan-migrate-fix-page-count-imbalance-on-node-stat.patch queue-6.1/migrate_pages-restrict-number-of-pages-to-migrate-in.patch queue-6.1/migrate_pages-split-unmap_and_move-to-_unmap-and-_mo.patch queue-6.1/mm-avoid-gcc-complaint-about-pointer-casting.patch queue-6.1/migrate_pages-organize-stats-with-struct-migrate_pag.patch queue-6.1/migrate_pages_batch-fix-statistics-for-longterm-pin-retry.patch