[PATCH v3]mm/oom-kill: direct hardware access processes should get bonus

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Figo.zhang
Date: Wednesday, November 10, 2010 - 8:24 am

the victim should not directly access hardware devices like Xorg server,
because the hardware could be left in an unpredictable state, although 
user-application can set /proc/pid/oom_score_adj to protect it. so i think
those processes should get bonus for protection.

in v2, fix the incorrect comment.
in v3, change the divided the badness score by 4, like old heuristic for protection. we just
want the oom_killer don't select Root/RESOURCE/RAWIO process as possible.

suppose that if a user process A such as email cleint "evolution" and a process B with
ditecly hareware access such as "Xorg", they have eat the equal memory (the badness score is 
the same),so which process are you want to kill? so in new heuristic, it will kill the process B.
but in reality, we want to kill process A.

Signed-off-by: Figo.zhang <figo1802@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/oom_kill.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 4029583..f43d759 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -202,6 +202,15 @@ unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
 		points -= 30;
 
 	/*
+	 * Root and direct hareware access processes are usually more 
+	 * important, so they should get bonus for protection. 
+	 */
+	if (has_capability_noaudit(p, CAP_SYS_ADMIN) ||
+	    has_capability_noaudit(p, CAP_SYS_RESOURCE) ||
+	    has_capability_noaudit(p, CAP_SYS_RAWIO))
+		points /= 4;
+
+	/*
 	 * /proc/pid/oom_score_adj ranges from -1000 to +1000 such that it may
 	 * either completely disable oom killing or always prefer a certain
 	 * task.


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH v2]oom-kill: CAP_SYS_RESOURCE should get bonus, David Rientjes, (Wed Nov 3, 4:47 pm)
Re:[PATCH v2]oom-kill: CAP_SYS_RESOURCE should get bonus, David Rientjes, (Wed Nov 3, 6:50 pm)
Re: [PATCH v2]oom-kill: CAP_SYS_RESOURCE should get bonus, KOSAKI Motohiro, (Tue Nov 9, 4:01 am)
Re: [PATCH v2]oom-kill: CAP_SYS_RESOURCE should get bonus, David Rientjes, (Tue Nov 9, 2:06 pm)
Re: [PATCH v2]oom-kill: CAP_SYS_RESOURCE should get bonus, David Rientjes, (Tue Nov 9, 2:25 pm)
[PATCH v3]mm/oom-kill: direct hardware access processes sh ..., Figo.zhang, (Wed Nov 10, 8:24 am)
Re: [PATCH v2]oom-kill: CAP_SYS_RESOURCE should get bonus, David Rientjes, (Wed Nov 10, 1:50 pm)
Re: [PATCH] Revert oom rewrite series, Figo.zhang, (Sun Nov 14, 8:26 pm)
Re: [PATCH] Revert oom rewrite series, David Rientjes, (Mon Nov 15, 3:14 am)
Re: [PATCH] Revert oom rewrite series, Alan Cox, (Mon Nov 15, 3:57 am)
Re: [PATCH] Revert oom rewrite series, David Rientjes, (Mon Nov 15, 1:54 pm)
Re: [PATCH] Revert oom rewrite series, KOSAKI Motohiro, (Tue Nov 23, 12:16 am)