path: root/mm
diff options
authorMuchun Song <>2021-02-04 18:32:17 -0800
committerLinus Torvalds <>2021-02-05 11:03:47 -0800
commit71a64f618be9594cd0645105c0989855c0f86d90 (patch)
tree06b2adc309c0ea17f899cf8447f86dd11d797b15 /mm
parentecbf4724e6061b4b01be20f6d797d64d462b2bc8 (diff)
mm: migrate: do not migrate HugeTLB page whose refcount is one
All pages isolated for the migration have an elevated reference count and therefore seeing a reference count equal to 1 means that the last user of the page has dropped the reference and the page has became unused and there doesn't make much sense to migrate it anymore. This has been done for regular pages and this patch does the same for hugetlb pages. Although the likelihood of the race is rather small for hugetlb pages it makes sense the two code paths in sync. Link: Signed-off-by: Muchun Song <> Reviewed-by: Mike Kravetz <> Acked-by: Yang Shi <> Acked-by: Michal Hocko <> Reviewed-by: David Hildenbrand <> Reviewed-by: Oscar Salvador <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm')
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/migrate.c b/mm/migrate.c
index c0efe921bca5..20ca887ea769 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1280,6 +1280,12 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
return -ENOSYS;
+ if (page_count(hpage) == 1) {
+ /* page was freed from under us. So we are done. */
+ putback_active_hugepage(hpage);
+ }
new_hpage = get_new_page(hpage, private);
if (!new_hpage)
return -ENOMEM;