add the 'goldfish' target, useful for experimenting with virtual phone hardware ...
[openwrt/svn-archive/archive.git] / target / linux / goldfish / patches-2.6.30 / 0052-lowmemorykiller-Only-iterate-over-process-list-when.patch
1 From 3742e6638bdb7325c6432e2a145ad985ee47d052 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:13:47 -0800
4 Subject: [PATCH 052/134] lowmemorykiller: Only iterate over process list when needed.
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=utf-8
7 Content-Transfer-Encoding: 8bit
8
9 Use NR_ACTIVE plus NR_INACTIVE as a size estimate for our fake cache
10 instead the sum of rss. Neither method is accurate.
11
12 Also skip the process scan, if the amount of memory available is above
13 the largest threshold set.
14
15 Signed-off-by: Arve Hjønnevåg <arve@android.com>
16 ---
17 drivers/staging/android/lowmemorykiller.c | 35 +++++++++++++++++-----------
18 1 files changed, 21 insertions(+), 14 deletions(-)
19
20 diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
21 index 3715d56..b9a2e84 100644
22 --- a/drivers/staging/android/lowmemorykiller.c
23 +++ b/drivers/staging/android/lowmemorykiller.c
24 @@ -71,23 +71,30 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
25 }
26 if(nr_to_scan > 0)
27 lowmem_print(3, "lowmem_shrink %d, %x, ofree %d, ma %d\n", nr_to_scan, gfp_mask, other_free, min_adj);
28 + rem = global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE);
29 + if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) {
30 + lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem);
31 + return rem;
32 + }
33 +
34 read_lock(&tasklist_lock);
35 for_each_process(p) {
36 - if(p->oomkilladj >= 0 && p->mm) {
37 - tasksize = get_mm_rss(p->mm);
38 - if(nr_to_scan > 0 && tasksize > 0 && p->oomkilladj >= min_adj) {
39 - if(selected == NULL ||
40 - p->oomkilladj > selected->oomkilladj ||
41 - (p->oomkilladj == selected->oomkilladj &&
42 - tasksize > selected_tasksize)) {
43 - selected = p;
44 - selected_tasksize = tasksize;
45 - lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
46 - p->pid, p->comm, p->oomkilladj, tasksize);
47 - }
48 - }
49 - rem += tasksize;
50 + if (p->oomkilladj < min_adj || !p->mm)
51 + continue;
52 + tasksize = get_mm_rss(p->mm);
53 + if (tasksize <= 0)
54 + continue;
55 + if (selected) {
56 + if (p->oomkilladj < selected->oomkilladj)
57 + continue;
58 + if (p->oomkilladj == selected->oomkilladj &&
59 + tasksize <= selected_tasksize)
60 + continue;
61 }
62 + selected = p;
63 + selected_tasksize = tasksize;
64 + lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
65 + p->pid, p->comm, p->oomkilladj, tasksize);
66 }
67 if(selected != NULL) {
68 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",
69 --
70 1.6.2
71