Commit 0cbef29a782162a3896487901eca4550bfa397ef

Authored by KOSAKI Motohiro
Committed by Linus Torvalds
1 parent 52c8f6a5ae

mm: __rmqueue_fallback() should respect pageblock type

When __rmqueue_fallback() doesn't find a free block with the required size
it splits a larger page and puts the rest of the page onto the free list.

But it has one serious mistake.  When putting back, __rmqueue_fallback()
always use start_migratetype if type is not CMA.  However,
__rmqueue_fallback() is only called when all of the start_migratetype
queue is empty.  That said, __rmqueue_fallback always puts back memory to
the wrong queue except try_to_steal_freepages() changed pageblock type
(i.e.  requested size is smaller than half of page block).  The end result
is that the antifragmentation framework increases fragmenation instead of
decreasing it.

Mel's original anti fragmentation does the right thing.  But commit
47118af076f6 ("mm: mmzone: MIGRATE_CMA migration type added") broke it.

This patch restores sane and old behavior.  It also removes an incorrect
comment which was introduced by commit fef903efcf0c ("mm/page_alloc.c:
restructure free-page stealing code and fix a bug").

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 5 additions and 10 deletions Side-by-side Diff

... ... @@ -1027,6 +1027,10 @@
1027 1027 {
1028 1028 int current_order = page_order(page);
1029 1029  
  1030 + /*
  1031 + * When borrowing from MIGRATE_CMA, we need to release the excess
  1032 + * buddy pages to CMA itself.
  1033 + */
1030 1034 if (is_migrate_cma(fallback_type))
1031 1035 return fallback_type;
1032 1036  
1033 1037  
... ... @@ -1091,17 +1095,8 @@
1091 1095 list_del(&page->lru);
1092 1096 rmv_page_order(page);
1093 1097  
1094   - /*
1095   - * Borrow the excess buddy pages as well, irrespective
1096   - * of whether we stole freepages, or took ownership of
1097   - * the pageblock or not.
1098   - *
1099   - * Exception: When borrowing from MIGRATE_CMA, release
1100   - * the excess buddy pages to CMA itself.
1101   - */
1102 1098 expand(zone, page, order, current_order, area,
1103   - is_migrate_cma(migratetype)
1104   - ? migratetype : start_migratetype);
  1099 + new_type);
1105 1100  
1106 1101 trace_mm_page_alloc_extfrag(page, order, current_order,
1107 1102 start_migratetype, migratetype, new_type);