From: David Rientjes Date: Wed, 11 Jul 2012 21:02:13 +0000 (-0700) Subject: mm, thp: abort compaction if migration page cannot be charged to memcg X-Git-Tag: upstream/snapshot3+hdmi~7098^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4bf2bba3750f10aa9e62e6949bc7e8329990f01b;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git mm, thp: abort compaction if migration page cannot be charged to memcg If page migration cannot charge the temporary page to the memcg, migrate_pages() will return -ENOMEM. This isn't considered in memory compaction however, and the loop continues to iterate over all pageblocks trying to isolate and migrate pages. If a small number of very large memcgs happen to be oom, however, these attempts will mostly be futile leading to an enormous amout of cpu consumption due to the page migration failures. This patch will short circuit and fail memory compaction if migrate_pages() returns -ENOMEM. COMPACT_PARTIAL is returned in case some migrations were successful so that the page allocator will retry. Signed-off-by: David Rientjes Acked-by: Mel Gorman Cc: Minchan Kim Cc: Kamezawa Hiroyuki Cc: Rik van Riel Cc: Andrea Arcangeli Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/compaction.c b/mm/compaction.c index 7ea259d..2f42d95 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -701,8 +701,11 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) if (err) { putback_lru_pages(&cc->migratepages); cc->nr_migratepages = 0; + if (err == -ENOMEM) { + ret = COMPACT_PARTIAL; + goto out; + } } - } out: