提交 5adc5be7 编写于 作者: M Mel Gorman 提交者: Linus Torvalds

Bias the placement of kernel pages at lower PFNs

This patch chooses blocks with lower PFNs when placing kernel allocations.
This is particularly important during fallback in low memory situations to
stop unmovable pages being placed throughout the entire address space.
Signed-off-by: NMel Gorman <mel@csn.ul.ie>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9ef9acb0
...@@ -765,6 +765,23 @@ int move_freepages_block(struct zone *zone, struct page *page, int migratetype) ...@@ -765,6 +765,23 @@ int move_freepages_block(struct zone *zone, struct page *page, int migratetype)
return move_freepages(zone, start_page, end_page, migratetype); return move_freepages(zone, start_page, end_page, migratetype);
} }
/* Return the page with the lowest PFN in the list */
static struct page *min_page(struct list_head *list)
{
unsigned long min_pfn = -1UL;
struct page *min_page = NULL, *page;;
list_for_each_entry(page, list, lru) {
unsigned long pfn = page_to_pfn(page);
if (pfn < min_pfn) {
min_pfn = pfn;
min_page = page;
}
}
return min_page;
}
/* Remove an element from the buddy allocator from the fallback list */ /* Remove an element from the buddy allocator from the fallback list */
static struct page *__rmqueue_fallback(struct zone *zone, int order, static struct page *__rmqueue_fallback(struct zone *zone, int order,
int start_migratetype) int start_migratetype)
...@@ -795,8 +812,11 @@ static struct page *__rmqueue_fallback(struct zone *zone, int order, ...@@ -795,8 +812,11 @@ static struct page *__rmqueue_fallback(struct zone *zone, int order,
if (list_empty(&area->free_list[migratetype])) if (list_empty(&area->free_list[migratetype]))
continue; continue;
/* Bias kernel allocations towards low pfns */
page = list_entry(area->free_list[migratetype].next, page = list_entry(area->free_list[migratetype].next,
struct page, lru); struct page, lru);
if (unlikely(start_migratetype != MIGRATE_MOVABLE))
page = min_page(&area->free_list[migratetype]);
area->nr_free--; area->nr_free--;
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册