BACKPORT: FROMLIST: mm/compaction: add support for >0 order folio memory compaction.
Before, memory compaction only migrates order-0 folios and skips >0 order folios. This commit adds support for >0 order folio compaction by keeping isolated free pages at their original size without splitting them into order-0 pages and using them directly during migration process. What is different from the prior implementation: 1. All isolated free pages are kept in a MAX_ORDER+1 array of page lists, where each page list stores free pages in the same order. 2. All free pages are not post_alloc_hook() processed nor buddy pages, although their orders are stored in first page's private like buddy pages. 3. During migration, in new page allocation time (i.e., in compaction_alloc()), free pages are then processed by post_alloc_hook(). When migration fails and a new page is returned (i.e., in compaction_free()), free pages are restored by reversing the post_alloc_hook() operations. Step 3 is done for a latter optimization that splitting and/or merging free pages during compaction becomes easier. Signed-off-by:Zi Yan <ziy@nvidia.com> Link: https://lore.kernel.org/linux-mm/20231113170157.280181-3-zi.yan@sent.com/ [Ryan: Converted use of MAX_ORDER to the old exclusive (0, MAX_ORDER] semantic, instead of the inclusive (0, MAX_ORDER) semantic in use on mainline] [Ryan: Converted use of page_rmappable_folio() to old prep_transhuge_page() equivalent] [Ryan: Converted PAGE_FLAGS_SECOND usage in compaction_free() to equivalent ops] Signed-off-by:
Ryan Roberts <ryan.roberts@arm.com>
Loading