lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1466487018-5410-3-git-send-email-opensource.ganesh@gmail.com>
Date:	Tue, 21 Jun 2016 13:30:18 +0800
From:	Ganesh Mahendran <opensource.ganesh@...il.com>
To:	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Cc:	gregkh@...uxfoundation.org, arve@...roid.com,
	riandrews@...roid.com,
	Ganesh Mahendran <opensource.ganesh@...il.com>
Subject: [PATCH 3/3] staging: lowmemorykiller: select the task with maximum rss to kill

Current task selecting logic in LMK does not fully aware of the memory
pressure. It may select the task with maximum score adj, but with
least tasksize.

For example, if min_score_adj is 200, and there are 2 tasks in system:
   task a: score adj 500, tasksize 200M
   task b: score adj 1000, tasksize 1M
Current LMK logic will select *task b*. But now the system already have
much memory pressure.

We should select the task with maximum task from all the tasks which
score adj >= min_score_adj.

Signed-off-by: Ganesh Mahendran <opensource.ganesh@...il.com>
---
 drivers/staging/android/lowmemorykiller.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 1d8de47..5fcfcfe 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -122,8 +122,6 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		return 0;
 	}
 
-	selected_oom_score_adj = min_score_adj;
-
 	rcu_read_lock();
 	for_each_process(tsk) {
 		struct task_struct *p;
@@ -151,18 +149,19 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		task_unlock(p);
 		if (tasksize <= 0)
 			continue;
-		if (selected) {
-			if (oom_score_adj < selected_oom_score_adj)
-				continue;
-			if (oom_score_adj == selected_oom_score_adj &&
-			    tasksize <= selected_tasksize)
-				continue;
+
+		/*
+		 * From the processes which score adj >= min_score_adj,
+		 * we select the one with the maximum tasksize.
+		 */
+		if (selected_tasksize < tasksize) {
+			selected = p;
+			selected_tasksize = tasksize;
+			selected_oom_score_adj = oom_score_adj;
+
+			lowmem_print(2, "select '%s' (%d), adj %hd, size %d, to kill\n",
+					 p->comm, p->pid, oom_score_adj, tasksize);
 		}
-		selected = p;
-		selected_tasksize = tasksize;
-		selected_oom_score_adj = oom_score_adj;
-		lowmem_print(2, "select '%s' (%d), adj %hd, size %d, to kill\n",
-			     p->comm, p->pid, oom_score_adj, tasksize);
 	}
 	if (selected) {
 		task_lock(selected);
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ