ps3: R.I.P.
[openwrt.git] / target / linux / goldfish / patches-2.6.30 / 0053-lowmemorykiller-Don-t-count-free-space-unless-it-me.patch
1 From f82da10dcae73652a6f0355e4398b4be1af17e6b Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com>
3 Date: Mon, 26 Jan 2009 19:22:19 -0800
4 Subject: [PATCH 053/134] lowmemorykiller: Don't count free space unless it meets the specified limit by itself
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=utf-8
7 Content-Transfer-Encoding: 8bit
8
9 This allows processes to be killed when the kernel evict cache pages in
10 an attempt to get more contiguous free memory.
11
12 Signed-off-by: Arve Hjønnevåg <arve@android.com>
13 ---
14  drivers/staging/android/lowmemorykiller.c |   13 +++++++++----
15  1 files changed, 9 insertions(+), 4 deletions(-)
16
17 --- a/drivers/staging/android/lowmemorykiller.c
18 +++ b/drivers/staging/android/lowmemorykiller.c
19 @@ -58,20 +58,25 @@ static int lowmem_shrink(int nr_to_scan,
20         int min_adj = OOM_ADJUST_MAX + 1;
21         int selected_tasksize = 0;
22         int array_size = ARRAY_SIZE(lowmem_adj);
23 -       int other_free = global_page_state(NR_FREE_PAGES) + global_page_state(NR_FILE_PAGES);
24 +       int other_free = global_page_state(NR_FREE_PAGES);
25 +       int other_file = global_page_state(NR_FILE_PAGES);
26         if(lowmem_adj_size < array_size)
27                 array_size = lowmem_adj_size;
28         if(lowmem_minfree_size < array_size)
29                 array_size = lowmem_minfree_size;
30         for(i = 0; i < array_size; i++) {
31 -               if(other_free < lowmem_minfree[i]) {
32 +               if (other_free < lowmem_minfree[i] &&
33 +                   other_file < lowmem_minfree[i]) {
34                         min_adj = lowmem_adj[i];
35                         break;
36                 }
37         }
38         if(nr_to_scan > 0)
39 -               lowmem_print(3, "lowmem_shrink %d, %x, ofree %d, ma %d\n", nr_to_scan, gfp_mask, other_free, min_adj);
40 -       rem = global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE);
41 +               lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n", nr_to_scan, gfp_mask, other_free, other_file, min_adj);
42 +       rem = global_page_state(NR_ACTIVE_ANON) +
43 +               global_page_state(NR_ACTIVE_FILE) +
44 +               global_page_state(NR_INACTIVE_ANON) +
45 +               global_page_state(NR_INACTIVE_FILE);
46         if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) {
47                 lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem);
48                 return rem;