CMA: make putback_lru_pages() call conditional
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Sat, 23 Feb 2013 00:32:09 +0000 (16:32 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 24 Feb 2013 01:50:09 +0000 (17:50 -0800)
As per documentation and other places calling putback_lru_pages(),
putback_lru_pages() is called on error only.  Make the CMA code behave
consistently.

[akpm@linux-foundation.org: remove a test-n-branch in the wrapup code]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/page_alloc.c

index d1107adf174a5390c597414ea335494e857f1af2..804cc62ab72f3c87685032a312f26ec0707d1d5d 100644 (file)
@@ -5806,9 +5806,11 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
                                    0, false, MIGRATE_SYNC,
                                    MR_CMA);
        }
-
-       putback_movable_pages(&cc->migratepages);
-       return ret > 0 ? 0 : ret;
+       if (ret < 0) {
+               putback_movable_pages(&cc->migratepages);
+               return ret;
+       }
+       return 0;
 }
 
 /**