Skip to content

Commit 1640a0e

Browse files
x-y-zakpm00
authored andcommitted
mm/memory_hotplug: use pfn math in place of direct struct page manipulation
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use pfn calculation to handle it properly. Without the fix, a wrong number of page might be skipped. Since skip cannot be negative, scan_movable_page() will end early and might miss a movable page with -ENOENT. This might fail offline_pages(). No bug is reported. The fix comes from code inspection. Link: https://lkml.kernel.org/r/[email protected] Fixes: eeb0efd ("mm,memory_hotplug: fix scan_movable_pages() for gigantic hugepages") Signed-off-by: Zi Yan <[email protected]> Reviewed-by: Muchun Song <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Mike Rapoport (IBM) <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 426056e commit 1640a0e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/memory_hotplug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
16891689
*/
16901690
if (HPageMigratable(head))
16911691
goto found;
1692-
skip = compound_nr(head) - (page - head);
1692+
skip = compound_nr(head) - (pfn - page_to_pfn(head));
16931693
pfn += skip - 1;
16941694
}
16951695
return -ENOENT;

0 commit comments

Comments
 (0)