public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/7] lowmemorykiller: Only iterate over process list when needed.
@ 2009-05-05  0:26 David Rientjes
  2009-05-05  0:26 ` [patch 2/7] lowmemorykiller: Don't count free space unless it meets the specified limit by itself David Rientjes
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: David Rientjes @ 2009-05-05  0:26 UTC (permalink / raw)
  To: Andrew Morton, Greg Kroah-Hartman
  Cc: Nick Piggin, San Mehat, Arve Hjønnevåg, linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2249 bytes --]

From: Arve Hjønnevåg <arve@android.com>

Use NR_ACTIVE plus NR_INACTIVE as a size estimate for our fake cache
instead the sum of rss. Neither method is accurate.

Also skip the process scan, if the amount of memory available is above
the largest threshold set.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
---
 drivers/staging/android/lowmemorykiller.c |   35 +++++++++++++++++-----------
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -71,23 +71,30 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
 	}
 	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);
+	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;
+	}
+
 	read_lock(&tasklist_lock);
 	for_each_process(p) {
-		if(p->oomkilladj >= 0 && p->mm) {
-			tasksize = get_mm_rss(p->mm);
-			if(nr_to_scan > 0 && tasksize > 0 && p->oomkilladj >= min_adj) {
-				if(selected == NULL ||
-				   p->oomkilladj > selected->oomkilladj ||
-				   (p->oomkilladj == selected->oomkilladj &&
-				    tasksize > selected_tasksize)) {
-					selected = p;
-					selected_tasksize = tasksize;
-					lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
-					             p->pid, p->comm, p->oomkilladj, tasksize);
-				}
-			}
-			rem += tasksize;
+		if (p->oomkilladj < min_adj || !p->mm)
+			continue;
+		tasksize = get_mm_rss(p->mm);
+		if (tasksize <= 0)
+			continue;
+		if (selected) {
+			if (p->oomkilladj < selected->oomkilladj)
+				continue;
+			if (p->oomkilladj == selected->oomkilladj &&
+			    tasksize <= selected_tasksize)
+				continue;
 		}
+		selected = p;
+		selected_tasksize = tasksize;
+		lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
+		             p->pid, p->comm, p->oomkilladj, tasksize);
 	}
 	if(selected != NULL) {
 		lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-05-05 18:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-05  0:26 [patch 1/7] lowmemorykiller: Only iterate over process list when needed David Rientjes
2009-05-05  0:26 ` [patch 2/7] lowmemorykiller: Don't count free space unless it meets the specified limit by itself David Rientjes
2009-05-05  0:26 ` [patch 3/7] oom: cleanup android low memory killer David Rientjes
2009-05-05  0:26 ` [patch 4/7] oom: fix possible android low memory killer NULL pointer David Rientjes
2009-05-05  0:27 ` [patch 5/7] oom: fix possible oom_dump_tasks " David Rientjes
2009-05-05 10:11   ` Nick Piggin
2009-05-05  0:27 ` [patch 6/7] oom: move oom_adj value from task_struct to mm_struct David Rientjes
2009-05-05 10:18   ` Nick Piggin
2009-05-05 18:29     ` David Rientjes
2009-05-05  0:27 ` [patch 7/7] oom: prevent possible OOM_DISABLE livelock David Rientjes
2009-05-05 10:22   ` Nick Piggin
2009-05-05 18:33     ` David Rientjes
2009-05-05 10:23 ` [patch 1/7] lowmemorykiller: Only iterate over process list when needed Nick Piggin
2009-05-05 16:31   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox