]> git.hungrycats.org Git - linux/commitdiff
mm: __rmqueue_fallback() should respect pageblock type
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Thu, 28 Aug 2014 18:34:23 +0000 (19:34 +0100)
committerJiri Slaby <jslaby@suse.cz>
Fri, 26 Sep 2014 09:51:52 +0000 (11:51 +0200)
commit 0cbef29a782162a3896487901eca4550bfa397ef upstream.

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>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
mm/page_alloc.c

index e285eaca2ba9f9604ab368f60fd72a4b9c226313..baef87ec4cf01904a8d65f0151c0ed365ef31b03 100644 (file)
@@ -1042,6 +1042,10 @@ static int try_to_steal_freepages(struct zone *zone, struct page *page,
 {
        int current_order = page_order(page);
 
+       /*
+        * When borrowing from MIGRATE_CMA, we need to release the excess
+        * buddy pages to CMA itself.
+        */
        if (is_migrate_cma(fallback_type))
                return fallback_type;
 
@@ -1106,17 +1110,8 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
                        list_del(&page->lru);
                        rmv_page_order(page);
 
-                       /*
-                        * Borrow the excess buddy pages as well, irrespective
-                        * of whether we stole freepages, or took ownership of
-                        * the pageblock or not.
-                        *
-                        * Exception: When borrowing from MIGRATE_CMA, release
-                        * the excess buddy pages to CMA itself.
-                        */
                        expand(zone, page, order, current_order, area,
-                              is_migrate_cma(migratetype)
-                            ? migratetype : start_migratetype);
+                              new_type);
 
                        trace_mm_page_alloc_extfrag(page, order, current_order,
                                start_migratetype, migratetype, new_type);