Ryan Roberts <ryan.roberts@xxxxxxx> writes: > Introduce FLEXIBLE_THP feature, which allows anonymous memory to be > allocated in large folios of a specified order. All pages of the large > folio are pte-mapped during the same page fault, significantly reducing > the number of page faults. The number of per-page operations (e.g. ref > counting, rmap management lru list management) are also significantly > reduced since those ops now become per-folio. I likes the idea to share as much code as possible between large (anonymous) folio and THP. Finally, THP becomes just a special kind of large folio. Although we can use smaller page order for FLEXIBLE_THP, it's hard to avoid internal fragmentation completely. So, I think that finally we will need to provide a mechanism for the users to opt out, e.g., something like "always madvise never" via /sys/kernel/mm/transparent_hugepage/enabled. I'm not sure whether it's a good idea to reuse the existing interface of THP. Best Regards, Huang, Ying