memfd_alloc_folio() adds a new hugetlb folio to the page cache, but never sets it migratable, unlike hugetlb_no_page() and hugetlbfs_fallocate(). Later faults will find it as an existing folio and never set the migratable flag. Such a folio can never be isolated for migration, even once it is no longer pinned, which breaks memory offlining, alloc_contig_range() and memory failure handling. Let's fix it by setting the new folio migratable after adding it to the page cache, like hugetlbfs_fallocate() already does. This has low urgency. Fixes: 89c1905d9c14 ("mm/gup: introduce memfd_pin_folios() for pinning memfd folios") Cc: Signed-off-by: David Hildenbrand (Arm) --- mm/memfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memfd.c b/mm/memfd.c index 0e02ca69d27cb..6340e8a7c4355 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -152,6 +152,7 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx) } hugetlb_set_folio_subpool(folio, subpool_inode(inode)); + folio_set_hugetlb_migratable(folio); folio_unlock(folio); filemap_invalidate_unlock_shared(memfd->f_mapping); mutex_unlock(&hugetlb_fault_mutex_table[hash]); -- 2.56.1