aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/android/lowmemorykiller.c
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2009-05-11 15:45:10 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 11:00:52 -0700
commit31d59a4198f3f07da8250dfb5b698eacfaf612e5 (patch)
treec081f22e80b3e2e6f86e3ea4c7155e86ff095030 /drivers/staging/android/lowmemorykiller.c
parentf501d00144328ca9e0521d159cf80ff5c9d21d77 (diff)
Staging: android: lowmemorykiller: Don't count free space unless it meets the specified limit by itself
From: Arve Hjønnevåg <arve@android.com> This allows processes to be killed when the kernel evict cache pages in an attempt to get more contiguous free memory. Signed-off-by: Arve Hjønnevåg <arve@android.com> Cc: David Rientjes <rientjes@google.com> Cc: San Mehat <san@android.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/android/lowmemorykiller.c')
-rw-r--r--drivers/staging/android/lowmemorykiller.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index b9a2e843e2f..b2ab7faac4f 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -58,20 +58,25 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
int min_adj = OOM_ADJUST_MAX + 1;
int selected_tasksize = 0;
int array_size = ARRAY_SIZE(lowmem_adj);
- int other_free = global_page_state(NR_FREE_PAGES) + global_page_state(NR_FILE_PAGES);
+ int other_free = global_page_state(NR_FREE_PAGES);
+ int other_file = global_page_state(NR_FILE_PAGES);
if(lowmem_adj_size < array_size)
array_size = lowmem_adj_size;
if(lowmem_minfree_size < array_size)
array_size = lowmem_minfree_size;
for(i = 0; i < array_size; i++) {
- if(other_free < lowmem_minfree[i]) {
+ if (other_free < lowmem_minfree[i] &&
+ other_file < lowmem_minfree[i]) {
min_adj = lowmem_adj[i];
break;
}
}
if(nr_to_scan > 0)
- lowmem_print(3, "lowmem_shrink %d, %x, ofree %d, ma %d\n", nr_to_scan, gfp_mask, other_free, min_adj);
- rem = global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE);
+ lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n", nr_to_scan, gfp_mask, other_free, other_file, min_adj);
+ rem = global_page_state(NR_ACTIVE_ANON) +
+ global_page_state(NR_ACTIVE_FILE) +
+ global_page_state(NR_INACTIVE_ANON) +
+ global_page_state(NR_INACTIVE_FILE);
if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) {
lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem);
return rem;