On 08/03/2024 13:24, David Hildenbrand wrote: >>>> This patch migrates the last subpage to a small folio and immediately >>>> returns the large folio to the system. It benefits both memory availability >>>> and anti-fragmentation. >>> >>> It might be controversial optimization, and as Ryan said, there, are likely >>> other cases where we'd want to migrate off-of a thp if possible earlier. >> >> Personally, I think there might also be cases where you want to copy/reuse the >> entire large folio. If you're application is using 16K THPs perhaps it's a >> bigger win to just treat it like a base page? I expect the cost/benefit will >> change as the THP size increases? > > Yes, I think for small folios (i.e., 16KiB) it will be rather easy to make a > decision. The larger the folio, the larger the page fault latency due to > scanning, copying, modifying, which can easily turn undesirable. > > At least when it comes to page reuse, I have some simple backup plans for small > folios if I won't be able to make progress with my other approach. Do you mean "small large folios" here? i.e. order >= 1? If so, great! For larger > folios, it won't really work/be desirable, though. >