On Wed, Mar 27, 2024 at 10:45:42AM -0400, Zi Yan wrote: > > for (pfn = start_pfn; pfn < end_pfn; pfn++) { > > - struct folio *folio; > > + struct page *page, *head; > > You could get rid of head too. It is only used to calculate next pfn, > so pfn = folio_to_pfn(folio) + folio_nr_pages(folio) - 1 would work. > > And the PageHuge(page) and PageTransHuge(page) can be simplified, since > their pfn calculations are the same. Something like: > > if (folio_test_large(folio)) { > pfn = folio_to_pfn(folio) + folio_nr_pages(folio) - 1; > if (folio_test_hugetlb(folio)) { > isolate_hugetlb(folio, &source); > continue; > } > } How much of this is safe without a refcount on the folio?