Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Arve Hjønnevåg and committed by
Greg Kroah-Hartman
31d59a41 f501d001

+9 -4
+9 -4
drivers/staging/android/lowmemorykiller.c
··· 58 58 int min_adj = OOM_ADJUST_MAX + 1; 59 59 int selected_tasksize = 0; 60 60 int array_size = ARRAY_SIZE(lowmem_adj); 61 - int other_free = global_page_state(NR_FREE_PAGES) + global_page_state(NR_FILE_PAGES); 61 + int other_free = global_page_state(NR_FREE_PAGES); 62 + int other_file = global_page_state(NR_FILE_PAGES); 62 63 if(lowmem_adj_size < array_size) 63 64 array_size = lowmem_adj_size; 64 65 if(lowmem_minfree_size < array_size) 65 66 array_size = lowmem_minfree_size; 66 67 for(i = 0; i < array_size; i++) { 67 - if(other_free < lowmem_minfree[i]) { 68 + if (other_free < lowmem_minfree[i] && 69 + other_file < lowmem_minfree[i]) { 68 70 min_adj = lowmem_adj[i]; 69 71 break; 70 72 } 71 73 } 72 74 if(nr_to_scan > 0) 73 - lowmem_print(3, "lowmem_shrink %d, %x, ofree %d, ma %d\n", nr_to_scan, gfp_mask, other_free, min_adj); 74 - rem = global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE); 75 + lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n", nr_to_scan, gfp_mask, other_free, other_file, min_adj); 76 + rem = global_page_state(NR_ACTIVE_ANON) + 77 + global_page_state(NR_ACTIVE_FILE) + 78 + global_page_state(NR_INACTIVE_ANON) + 79 + global_page_state(NR_INACTIVE_FILE); 75 80 if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) { 76 81 lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem); 77 82 return rem;