diff mbox series

mm: page_alloc: remove MIGRATE_HIGHATOMIC order0 page

Message ID 20230905153230.1291-1-justinjiang@vivo.com (mailing list archive)
State New
Headers show
Series mm: page_alloc: remove MIGRATE_HIGHATOMIC order0 page | expand

Commit Message

zhiguojiang Sept. 5, 2023, 3:32 p.m. UTC
The MIGRATE_HIGHATOMIC pages are used for order > 0 allocation,
so pages in MIGRATE_HIGHATOMIC order0 freelist are invalid.

This patch can solve the allocation failure from buddy, due to
the reserved MIGRATE_HIGHATOMIC order0 pages.

Signed-off-by: Zhiguo Jiang <justinjiang@vivo.com>
---
 mm/page_alloc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 14b51d1ef4c3..10c5b053bedf 100755
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -831,6 +831,9 @@  static inline void __free_one_page(struct page *page,
 	else
 		to_tail = buddy_merge_likely(pfn, buddy_pfn, page, order);
 
+	if (unlikely(!order && is_migrate_highatomic(migratetype)))
+		migratetype = MIGRATE_MOVABLE;
+
 	if (to_tail)
 		add_to_free_list_tail(page, zone, order, migratetype);
 	else
@@ -1639,9 +1642,13 @@  static int move_freepages(struct zone *zone,
 		VM_BUG_ON_PAGE(page_zone(page) != zone, page);
 
 		order = buddy_order(page);
-		move_to_free_list(page, zone, order, migratetype);
+		if (unlikely(!order && is_migrate_highatomic(migratetype)))
+			move_to_free_list(page, zone, order, MIGRATE_MOVABLE);
+		else {
+			move_to_free_list(page, zone, order, migratetype);
+			pages_moved += 1 << order;
+		}
 		pfn += 1 << order;
-		pages_moved += 1 << order;
 	}
 
 	return pages_moved;