android/lowmemorykiller: Account for total_swapcache_pages

The lowmemorykiller relies on NR_FILE_PAGES when measureing
the amount of reclaimable memory in the system.
However when swap is enabled swap cache pages are counted
in NR_FILE_PAGES, and swap cache pages aren't as reclaimable
in low memory as file cache pages. Therefore a large swap
cache can result in the lowmemorykiller not running and
an OOM occuring.

In order to ensure the lowmemorykiller properly evaluates the
amount of reclaimable memory don't count the swap cache pages.

Change-Id: I38239283e572f814b277c718eaf6be7f92abacbb
Signed-off-by: Liam Mark <lmark@codeaurora.org>
This commit is contained in:
Liam Mark 2013-08-30 12:10:39 -07:00
parent b26a0ee6b1
commit 3a610c281c
1 changed files with 9 additions and 2 deletions

View File

@ -43,6 +43,7 @@
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/swap.h>
#include <linux/fs.h>
#ifdef CONFIG_HIGHMEM
#define _ZONE ZONE_HIGHMEM
@ -250,8 +251,14 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
}
other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM);
if (global_page_state(NR_SHMEM) + total_swapcache_pages() <
global_page_state(NR_FILE_PAGES))
other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM) -
total_swapcache_pages();
else
other_file = 0;
tune_lmk_param(&other_free, &other_file, sc);