migrate_pages_batch: fix statistics for longterm pin retry
authorHuang Ying <ying.huang@intel.com>
Sun, 16 Apr 2023 23:59:29 +0000 (07:59 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 21 Apr 2023 21:52:02 +0000 (14:52 -0700)
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@intel.com
Fixes: fd4a7ac32918 ("mm: migrate: try again if THP split is failed due to page refcnt")
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/migrate.c

index 41f2154..5d95e09 100644 (file)
@@ -1710,6 +1710,9 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
                                                        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;
                                                }
                                        }