Message ID | 20220711084948.274787-7-ying.huang@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [-V2,1/7] migrate: fix syscall move_pages() return value for failure | expand |
On Mon, Jul 11, 2022 at 04:49:47PM +0800, Huang Ying wrote: > If THP is failed to be migrated, it may be split and retry. But after > splitting, the head page will be left in "from" list, although THP > migration failure has been counted already. If the head page is > failed to be migrated too, the failure will be counted twice > incorrectly. So this is fixed in this patch via moving the head page > of THP after splitting to "thp_split_pages" too. > > Signed-off-by: "Huang, Ying" <ying.huang@intel.com> > Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") > Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> > Cc: Zi Yan <ziy@nvidia.com> > Cc: Yang Shi <shy828301@gmail.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> > --- > mm/migrate.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 8cce73b7c046..557708ce13a1 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1306,6 +1306,8 @@ static inline int try_split_thp(struct page *page, struct list_head *split_pages > lock_page(page); > rc = split_huge_page_to_list(page, split_pages); > unlock_page(page); > + if (!rc) > + list_move_tail(&page->lru, split_pages); > > return rc; > } > @@ -1365,7 +1367,6 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > thp_retry = 0; > > list_for_each_entry_safe(page, page2, from, lru) { > -retry: > /* > * THP statistics is based on the source huge page. > * Capture required information that might get lost > @@ -1412,7 +1413,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > nr_thp_failed++; > if (!try_split_thp(page, &thp_split_pages)) { > nr_thp_split++; > - goto retry; > + break; > } > /* Hugetlb migration is unsupported */ > } else if (!no_subpage_counting) { > @@ -1432,7 +1433,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > /* THP NUMA faulting doesn't split THP to retry. */ > if (!nosplit && !try_split_thp(page, &thp_split_pages)) { > nr_thp_split++; > - goto retry; > + break; > } > } else if (!no_subpage_counting) { > nr_failed++; > -- > 2.30.2 > >
diff --git a/mm/migrate.c b/mm/migrate.c index 8cce73b7c046..557708ce13a1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1306,6 +1306,8 @@ static inline int try_split_thp(struct page *page, struct list_head *split_pages lock_page(page); rc = split_huge_page_to_list(page, split_pages); unlock_page(page); + if (!rc) + list_move_tail(&page->lru, split_pages); return rc; } @@ -1365,7 +1367,6 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, thp_retry = 0; list_for_each_entry_safe(page, page2, from, lru) { -retry: /* * THP statistics is based on the source huge page. * Capture required information that might get lost @@ -1412,7 +1413,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, nr_thp_failed++; if (!try_split_thp(page, &thp_split_pages)) { nr_thp_split++; - goto retry; + break; } /* Hugetlb migration is unsupported */ } else if (!no_subpage_counting) { @@ -1432,7 +1433,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, /* THP NUMA faulting doesn't split THP to retry. */ if (!nosplit && !try_split_thp(page, &thp_split_pages)) { nr_thp_split++; - goto retry; + break; } } else if (!no_subpage_counting) { nr_failed++;