ANDROID: GKI: mm: fix cma accounting in zone_watermark_ok

Some cases were reported on 3.18 where atomic unmovable allocations
of order 2 fails, but kswapd does not wakeup. And in such cases it
was seen that, when zone_watermark_ok check is  performed to decide
whether to wake up kswapd, there were lot of CMA pages of order 2 and
above. This makes the watermark check succeed resulting in kswapd not
being woken up. But since these atomic unmovable allocations can't come
from CMA region, further atomic allocations keeps failing, without
kswapd trying to reclaim. Usually concurrent movable allocations result
in reclaim and improves the situtation, but the case reported was from
a network test which was resulting in only atomic skb allocations being
attempted. On 3.18 this was fixed by adding a cma free page counter and
accouting the cma free pages properly in watermark calculations.

Later this issue was indirectly fixed by the commit "mm, page_alloc:
only enforce watermarks for order-0 allocations".

But the commit "mm: add cma pcp list" brought the problem back because
it includes MIGRATE_CMA within MIGRATE_PCPTYPES, and thus watermark
check erroneously returns success for !ALLOC_CMA by finding free pages
in cma free list.

Change-Id: Id0e48b5c2f9deea93c5875c10d5ec72bd360df5f
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>

Bug: 150808082
Test: build
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I232e5379797ae946e15127852d31c2d29ca35b30
1 file changed