android: lowmemkiller: don't consider CMA memory as free
Krishna Reddy [Sat, 27 Sep 2014 00:14:03 +0000 (17:14 -0700)]
As CMA memory can only be used for Movable allocations,
Android lowmemkiller shouldn't consider this as free memory
for lowmem kill decisions.  If it considered as free memory,
It can delay the killing of apps and lead to slowness of
system as memory allocations start waiting for kswap
daemon to free up the memory.

Bug 1550455

Change-Id: Ica8da48ef48912d89cde526f0ba3676df6ab10f1
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/542209
(cherry picked from commit 24a7d99f9117e250dbf276d453c336b31dc2c127)
Reviewed-on: http://git-master/r/592901
GVS: Gerrit_Virtual_Submit
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>

drivers/staging/android/lowmemorykiller.c

index 2c72aec..30209e8 100644 (file)
@@ -80,7 +80,8 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
        int selected_tasksize = 0;
        short selected_oom_score_adj;
        int array_size = ARRAY_SIZE(lowmem_adj);
-       int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages
+       int other_free = global_page_state(NR_FREE_PAGES) -
+                        global_page_state(NR_FREE_CMA_PAGES) - totalreserve_pages
 #ifdef CONFIG_TEGRA_NVMAP
                         + nvmap_page_pool_get_unused_pages()
 #endif