1 From ff59909a077b3c51c168cb658601c6b63136a347 Mon Sep 17 00:00:00 2001
2 From: Hugh Dickins <hughd@google.com>
3 Date: Thu, 12 Feb 2015 15:00:28 -0800
4 Subject: mm: fix negative nr_isolated counts
6 From: Hugh Dickins <hughd@google.com>
8 commit ff59909a077b3c51c168cb658601c6b63136a347 upstream.
10 The vmstat interfaces are good at hiding negative counts (at least when
11 CONFIG_SMP); but if you peer behind the curtain, you find that
12 nr_isolated_anon and nr_isolated_file soon go negative, and grow ever
13 more negative: so they can absorb larger and larger numbers of isolated
14 pages, yet still appear to be zero.
16 I'm happy to avoid a congestion_wait() when too_many_isolated() myself;
17 but I guess it's there for a good reason, in which case we ought to get
18 too_many_isolated() working again.
20 The imbalance comes from isolate_migratepages()'s ISOLATE_ABORT case:
21 putback_movable_pages() decrements the NR_ISOLATED counts, but we forgot
22 to call acct_isolated() to increment them.
24 It is possible that the bug whcih this patch fixes could cause OOM kills
25 when the system still has a lot of reclaimable page cache.
27 Fixes: edc2ca612496 ("mm, compaction: move pageblock checks up from isolate_migratepages_range()")
28 Signed-off-by: Hugh Dickins <hughd@google.com>
29 Acked-by: Vlastimil Babka <vbabka@suse.cz>
30 Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
31 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
32 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36 mm/compaction.c | 4 +++-
37 1 file changed, 3 insertions(+), 1 deletion(-)
41 @@ -1015,8 +1015,10 @@ static isolate_migrate_t isolate_migrate
42 low_pfn = isolate_migratepages_block(cc, low_pfn, end_pfn,
45 - if (!low_pfn || cc->contended)
46 + if (!low_pfn || cc->contended) {
47 + acct_isolated(zone, cc);
52 * Either we isolated something and proceed with migration. Or