Skip to content

Commit 46dafbc

Browse files
gormanmLinus Torvalds
authored andcommitted
Be more agressive about stealing when MIGRATE_RECLAIMABLE allocations fallback
MIGRATE_RECLAIMABLE allocations tend to be very bursty in nature like when updatedb starts. It is likely this will occur in situations where MAX_ORDER blocks of pages are not free. This means that updatedb can scatter MIGRATE_RECLAIMABLE pages throughout the address space. This patch is more agressive about stealing blocks of pages for MIGRATE_RECLAIMABLE. Signed-off-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5adc5be commit 46dafbc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

mm/page_alloc.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,23 @@ static struct page *__rmqueue_fallback(struct zone *zone, int order,
821821

822822
/*
823823
* If breaking a large block of pages, move all free
824-
* pages to the preferred allocation list
824+
* pages to the preferred allocation list. If falling
825+
* back for a reclaimable kernel allocation, be more
826+
* agressive about taking ownership of free pages
825827
*/
826-
if (unlikely(current_order >= MAX_ORDER / 2)) {
828+
if (unlikely(current_order >= MAX_ORDER / 2) ||
829+
start_migratetype == MIGRATE_RECLAIMABLE) {
830+
unsigned long pages;
831+
pages = move_freepages_block(zone, page,
832+
start_migratetype);
833+
834+
/* Claim the whole block if over half of it is free */
835+
if ((pages << current_order) >= (1 << (MAX_ORDER-2)) &&
836+
migratetype != MIGRATE_HIGHATOMIC)
837+
set_pageblock_migratetype(page,
838+
start_migratetype);
839+
827840
migratetype = start_migratetype;
828-
move_freepages_block(zone, page, migratetype);
829841
}
830842

831843
/* Remove the page from the freelists */

0 commit comments

Comments
 (0)