Skip to content
Commit 1178b458 authored by Zi Yan's avatar Zi Yan Committed by Ryan Roberts
Browse files

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: default avatarZi 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's avatarRyan Roberts <ryan.roberts@arm.com>
parent deb4735a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment