Re: [PATCH] mm/hugetlb: mm/memory_hotplug: use a folio in scan_movable_pages()

From: Sidhartha Kumar
Date: Wed May 29 2024 - 14:21:47 EST


On 5/28/24 3:47 PM, Matthew Wilcox wrote:
On Tue, May 28, 2024 at 03:03:21PM -0700, Sidhartha Kumar wrote:
@@ -1761,9 +1762,9 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
* cases false positives and negatives are possible. Calling
* code must deal with these scenarios.
*/
- if (HPageMigratable(head))
+ if (folio_test_hugetlb_migratable(folio))
goto found;
- skip = compound_nr(head) - (pfn - page_to_pfn(head));
+ skip = folio_nr_pages(folio) - folio_page_idx(folio, page);
pfn += skip - 1;

Isn't this an unnecessarily complicated way of writing:

pfn |= folio_nr_pages(folio) - 1;
?

Because folio_nr_pages() is a power of 2, I agree this is simpler. I'll make this change in a v2.

Thanks,
Sid