Skip to content

Commit

Permalink
mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migr…
Browse files Browse the repository at this point in the history
…ation()

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 e66f17f
("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

Link: https://lkml.kernel.org/r/20230913095131.2426871-8-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Kefeng Wang authored and Andrew Morton committed Oct 4, 2023
1 parent d64cfcc commit b426ed7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2096,10 +2096,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) {
Expand Down

0 comments on commit b426ed7

Please sign in to comment.