[RFC] oom-kill: give the dying task a higher priority

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Luis Claudio R. Goncalves
Date: Thursday, May 27, 2010 - 11:04 am

Hello,

Could you please review this patch?

The idea behind it is quite simple: give the dying task a higher priority
so that it can be scheduled sooner and die to free memory.


oom-kill: give the dying task a higher priority

In a system under heavy load it was observed that even after the
oom-killer selects a task to die, the task may take a long time to die.

Right before sending a SIGKILL to the selected task the oom-killer
increases the task priority so that it can exit quickly, freeing memory.
That is accomplished by:

        /*
         * We give our sacrificial lamb high priority and access to
         * all the memory it needs. That way it should be able to
         * exit() and clear out its resources quickly...
         */
 	p->rt.time_slice = HZ;
 	set_tsk_thread_flag(p, TIF_MEMDIE);

It sounds plausible giving the dying task an even higher priority to be
sure it will be scheduled sooner and free the desired memory.

Signed-off-by: Luis Claudio R. Gonçalves <lclaudio@uudg.org>

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index b68e802..8047309 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -382,6 +382,8 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order,
  */
 static void __oom_kill_task(struct task_struct *p, int verbose)
 {
+	struct sched_param param;
+
 	if (is_global_init(p)) {
 		WARN_ON(1);
 		printk(KERN_WARNING "tried to kill init!\n");
@@ -413,6 +415,8 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
 	 */
 	p->rt.time_slice = HZ;
 	set_tsk_thread_flag(p, TIF_MEMDIE);
+	param.sched_priority = MAX_RT_PRIO-1;
+	sched_setscheduler(p, SCHED_FIFO, &param);
 
 	force_sig(SIGKILL, p);
 }


Thanks,
Luis
-- 
[ Luis Claudio R. Goncalves                    Bass - Gospel - RT ]
[ Fingerprint: 4FDD B8C4 3C59 34BD 8BE9  2696 7203 D980 A448 C8F8 ]

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

Messages in current thread:
[RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Thu May 27, 11:04 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Oleg Nesterov, (Thu May 27, 11:33 am)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Thu May 27, 7:54 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Thu May 27, 8:51 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Thu May 27, 9:46 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Thu May 27, 10:39 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Thu May 27, 10:59 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, Balbir Singh, (Thu May 27, 11:27 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Thu May 27, 11:34 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Thu May 27, 11:38 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Fri May 28, 5:53 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Fri May 28, 7:36 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Peter Zijlstra, (Fri May 28, 8:21 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Fri May 28, 8:28 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Peter Zijlstra, (Fri May 28, 8:53 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Fri May 28, 9:48 am)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Fri May 28, 8:59 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Sun May 30, 5:21 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Sun May 30, 7:15 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Sun May 30, 10:04 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Sun May 30, 10:54 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Sun May 30, 11:35 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Sun May 30, 11:51 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Mon May 31, 12:25 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Mon May 31, 6:52 am)
Re: [RFC] oom-kill: give the dying task a higher priority, KAMEZAWA Hiroyuki, (Mon May 31, 4:50 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Tue Jun 1, 10:35 am)
Re: [RFC] oom-kill: give the dying task a higher priority, David Rientjes, (Tue Jun 1, 11:36 am)
Re: [RFC] oom-kill: give the dying task a higher priority, David Rientjes, (Tue Jun 1, 1:49 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Wed Jun 2, 6:54 am)
Re: [RFC] oom-kill: give the dying task a higher priority, Luis Claudio R. Gonc ..., (Wed Jun 2, 7:20 am)
Re: [RFC] oom-kill: give the dying task a higher priority, David Rientjes, (Wed Jun 2, 2:11 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, KOSAKI Motohiro, (Wed Jun 2, 4:36 pm)
Re: [RFC] oom-kill: give the dying task a higher priority, Peter Zijlstra, (Thu Jun 3, 12:50 am)
Re: [RFC] oom-kill: give the dying task a higher priority, David Rientjes, (Thu Jun 3, 1:32 pm)