mm, compaction: prevent VM_BUG_ON when terminating freeing scanner
authorDavid Rientjes <rientjes@google.com>
Thu, 14 Jul 2016 19:06:50 +0000 (12:06 -0700)
committerSasha Levin <alexander.levin@verizon.com>
Sat, 6 Aug 2016 16:58:59 +0000 (12:58 -0400)
commitfe071fb0d4e9fd40fe7c46c6a9f8f23d5f27e92f
treeef3f593664896ddcff9dbf4285dc585d1ea85bf3
parentca0d868322c49b0d6ee4dfaae94a28e12969552c
mm, compaction: prevent VM_BUG_ON when terminating freeing scanner

[ Upstream commit a46cbf3bc53b6a93fb84a5ffb288c354fa807954 ]

It's possible to isolate some freepages in a pageblock and then fail
split_free_page() due to the low watermark check.  In this case, we hit
VM_BUG_ON() because the freeing scanner terminated early without a
contended lock or enough freepages.

This should never have been a VM_BUG_ON() since it's not a fatal
condition.  It should have been a VM_WARN_ON() at best, or even handled
gracefully.

Regardless, we need to terminate anytime the full pageblock scan was not
done.  The logic belongs in isolate_freepages_block(), so handle its
state gracefully by terminating the pageblock loop and making a note to
restart at the same pageblock next time since it was not possible to
complete the scan this time.

[rientjes@google.com: don't rescan pages in a pageblock]
Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1607111244150.83138@chino.kir.corp.google.com
Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1606291436300.145590@chino.kir.corp.google.com
Signed-off-by: David Rientjes <rientjes@google.com>
Reported-by: Minchan Kim <minchan@kernel.org>
Tested-by: Minchan Kim <minchan@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
mm/compaction.c