Skip to content

Commit 585fc0d

Browse files
Muchun Songtorvalds
authored andcommitted
mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page
If a new hugetlb page is allocated during fallocate it will not be marked as active (set_page_huge_active) which will result in a later isolate_huge_page failure when the page migration code would like to move that page. Such a failure would be unexpected and wrong. Only export set_page_huge_active, just leave clear_page_huge_active as static. Because there are no external users. Link: https://lkml.kernel.org/r/20210115124942.46403-3-songmuchun@bytedance.com Fixes: 70c3547 (hugetlbfs: add hugetlbfs_fallocate()) Signed-off-by: Muchun Song <songmuchun@bytedance.com> Acked-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Cc: David Hildenbrand <david@redhat.com> Cc: Yang Shi <shy828301@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5c279c4 commit 585fc0d

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

fs/hugetlbfs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,9 +735,10 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
735735

736736
mutex_unlock(&hugetlb_fault_mutex_table[hash]);
737737

738+
set_page_huge_active(page);
738739
/*
739740
* unlock_page because locked by add_to_page_cache()
740-
* page_put due to reference from alloc_huge_page()
741+
* put_page() due to reference from alloc_huge_page()
741742
*/
742743
unlock_page(page);
743744
put_page(page);

include/linux/hugetlb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
770770
}
771771
#endif
772772

773+
void set_page_huge_active(struct page *page);
774+
773775
#else /* CONFIG_HUGETLB_PAGE */
774776
struct hstate {};
775777

mm/hugetlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ bool page_huge_active(struct page *page)
13491349
}
13501350

13511351
/* never called for tail page */
1352-
static void set_page_huge_active(struct page *page)
1352+
void set_page_huge_active(struct page *page)
13531353
{
13541354
VM_BUG_ON_PAGE(!PageHeadHuge(page), page);
13551355
SetPagePrivate(&page[1]);

0 commit comments

Comments
 (0)