Commit 95e34412 authored by Minchan Kim's avatar Minchan Kim Committed by Linus Torvalds
Browse files

mm: remain migratetype in freed page

The page allocator caches the pageblock information in page->private while
it is in the PCP freelists but this is overwritten with the order of the
page when freed to the buddy allocator.  This patch stores the migratetype
of the page in the page->index field so that it is available at all times
when the page remain in free_list.

This patch adds a new call site in __free_pages_ok so it might be overhead
a bit but it's for high order allocation.  So I believe damage isn't hurt.
Signed-off-by: default avatarMinchan Kim <>
Acked-by: default avatarKAMEZAWA Hiroyuki <>
Reviewed-by: default avatarYasuaki Ishimatsu <>
Acked-by: default avatarMel Gorman <>
Cc: Xishi Qiu <>
Cc: Wen Congyang <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent b12c4ad1
......@@ -240,13 +240,13 @@ struct inode;
/* It's valid only if the page is free path or free_list */
static inline void set_freepage_migratetype(struct page *page, int migratetype)
set_page_private(page, migratetype);
page->index = migratetype;
/* It's valid only if the page is free path or free_list */
static inline int get_freepage_migratetype(struct page *page)
return page_private(page);
return page->index;
......@@ -729,6 +729,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
unsigned long flags;
int wasMlocked = __TestClearPageMlocked(page);
int migratetype;
if (!free_pages_prepare(page, order))
......@@ -737,8 +738,9 @@ static void __free_pages_ok(struct page *page, unsigned int order)
if (unlikely(wasMlocked))
__count_vm_events(PGFREE, 1 << order);
free_one_page(page_zone(page), page, order,
migratetype = get_pageblock_migratetype(page);
set_freepage_migratetype(page, migratetype);
free_one_page(page_zone(page), page, order, migratetype);
......@@ -959,6 +961,7 @@ static int move_freepages(struct zone *zone,
order = page_order(page);
set_freepage_migratetype(page, migratetype);
page += 1 << order;
pages_moved += 1 << order;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment