[kernel] fix samsung flash patch after r21408, thanks to Matthias Buecher (#7348)
[openwrt.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 --- a/drivers/staging/android/lowmemorykiller.c
21 +++ b/drivers/staging/android/lowmemorykiller.c
22 @@ -71,23 +71,30 @@ static int lowmem_shrink(int nr_to_scan,
23 }
24 if(nr_to_scan > 0)
25 lowmem_print(3, "lowmem_shrink %d, %x, ofree %d, ma %d\n", nr_to_scan, gfp_mask, other_free, min_adj);
26 + rem = global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE);
27 + if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) {
28 + lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem);
29 + return rem;
30 + }
31 +
32 read_lock(&tasklist_lock);
33 for_each_process(p) {
34 - if(p->oomkilladj >= 0 && p->mm) {
35 - tasksize = get_mm_rss(p->mm);
36 - if(nr_to_scan > 0 && tasksize > 0 && p->oomkilladj >= min_adj) {
37 - if(selected == NULL ||
38 - p->oomkilladj > selected->oomkilladj ||
39 - (p->oomkilladj == selected->oomkilladj &&
40 - tasksize > selected_tasksize)) {
41 - selected = p;
42 - selected_tasksize = tasksize;
43 - lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
44 - p->pid, p->comm, p->oomkilladj, tasksize);
45 - }
46 - }
47 - rem += tasksize;
48 + if (p->oomkilladj < min_adj || !p->mm)
49 + continue;
50 + tasksize = get_mm_rss(p->mm);
51 + if (tasksize <= 0)
52 + continue;
53 + if (selected) {
54 + if (p->oomkilladj < selected->oomkilladj)
55 + continue;
56 + if (p->oomkilladj == selected->oomkilladj &&
57 + tasksize <= selected_tasksize)
58 + continue;
59 }
60 + selected = p;
61 + selected_tasksize = tasksize;
62 + lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
63 + p->pid, p->comm, p->oomkilladj, tasksize);
64 }
65 if(selected != NULL) {
66 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",
This page took 0.051557 seconds and 5 git commands to generate.