Comment: Both will eventually loop over all orders, correct? Could eventually be sped up in the future. Nit: the orders = ... order = ... looks like this might deserve a helper function that makes this easier to read. Nit: Why call thp_vma_suitable_orders if the orders are already 0? Again, some helper might be reasonable where that is handled internally. Comment: For order-0 we'll always perform a function call to both thp_vma_allowable_orders() / thp_vma_suitable_orders(). We should perform some fast and efficient check if any <PMD THP are even enabled in the system / for this VMA, and in that case just fallback before doing more expensive checks.
Correction: only a call to thp_vma_allowable_orders(). I wonder if we can move some of thp_vma_allowable_orders() into the header file where we'd just check as fast and as efficiently for "no THP < PMD_THP enabled" on this system.
-- Cheers, David / dhildenb