[PATCH v2 7/8] mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migration()

From: Kefeng Wang
Date: Mon Aug 21 2023 - 07:45:55 EST


There is some different between hugeTLB and THP behave when passed the
address of a tail page, for THP, it will migrate the entire THP page,
but for HugeTLB, it will return -EACCES, or -ENOENT before commit
e66f17ff7177 ("mm/hugetlb: take page table lock in follow_huge_pmd()"),

-EACCES The page is mapped by multiple processes and can be moved
only if MPOL_MF_MOVE_ALL is specified.
-ENOENT The page is not present.

But when check manual[1], both of the two errnos are not suitable, it
is better to keep the same behave between hugetlb and THP when passed
the address of a tail page, so let's just remove the PageHead() check
for HugeTLB.

[1] https://man7.org/linux/man-pages/man2/move_pages.2.html

Suggested-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
---
mm/migrate.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 73572d5a5cd4..e8c3fb8974f9 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2093,10 +2093,8 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p,
goto out_putfolio;

if (folio_test_hugetlb(folio)) {
- if (PageHead(page)) {
- isolated = isolate_hugetlb(folio, pagelist);
- err = isolated ? 1 : -EBUSY;
- }
+ isolated = isolate_hugetlb(folio, pagelist);
+ err = isolated ? 1 : -EBUSY;
} else {
isolated = folio_isolate_lru(folio);
if (!isolated) {
--
2.41.0