linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch -mm] memcg: make oom killer a no-op when no killable task can be found
@ 2010-05-04 23:51 David Rientjes
  0 siblings, 0 replies; 29+ messages in thread
From: David Rientjes @ 2010-05-04 23:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: KAMEZAWA Hiroyuki, Balbir Singh, linux-mm

It's pointless to try to kill current if select_bad_process() did not
find an eligible task to kill in mem_cgroup_out_of_memory() since it's
guaranteed that current is a member of the memcg that is oom and it is,
by definition, unkillable.

Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/oom_kill.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -512,12 +512,9 @@ void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask)
 	read_lock(&tasklist_lock);
 retry:
 	p = select_bad_process(&points, limit, mem, CONSTRAINT_NONE, NULL);
-	if (PTR_ERR(p) == -1UL)
+	if (!p || PTR_ERR(p) == -1UL)
 		goto out;
 
-	if (!p)
-		p = current;
-
 	if (oom_kill_process(p, gfp_mask, 0, points, limit, mem,
 				"Memory cgroup out of memory"))
 		goto retry;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 29+ messages in thread
* Re: [PATCH] oom killer: break from infinite loop
@ 2010-03-28 14:55 anfei
  2010-03-28 16:28 ` Oleg Nesterov
  0 siblings, 1 reply; 29+ messages in thread
From: anfei @ 2010-03-28 14:55 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, rientjes, kosaki.motohiro, nishimura,
	kamezawa.hiroyu, linux-mm, linux-kernel

On Fri, Mar 26, 2010 at 11:33:56PM +0100, Oleg Nesterov wrote:
> On 03/26, Andrew Morton wrote:
> >
> > On Thu, 25 Mar 2010 00:25:05 +0800
> > Anfei Zhou <anfei.zhou@gmail.com> wrote:
> >
> > > --- a/mm/oom_kill.c
> > > +++ b/mm/oom_kill.c
> > > @@ -381,6 +381,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 task_struct *t;
> > > +
> > >  	if (is_global_init(p)) {
> > >  		WARN_ON(1);
> > >  		printk(KERN_WARNING "tried to kill init!\n");
> > > @@ -412,6 +414,8 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
> > >  	 */
> > >  	p->rt.time_slice = HZ;
> > >  	set_tsk_thread_flag(p, TIF_MEMDIE);
> > > +	for (t = next_thread(p); t != p; t = next_thread(t))
> > > +		set_tsk_thread_flag(t, TIF_MEMDIE);
> > >
> > >  	force_sig(SIGKILL, p);
> >
> > Don't we need some sort of locking while walking that ring?
> 
> This should be always called under tasklist_lock, I think.
> At least this seems to be true in Linus's tree.
> 
Yes, this function is always called with read_lock(&tasklist_lock), so
it should be okay.

> I'd suggest to do
> 
> 	- set_tsk_thread_flag(p, TIF_MEMDIE);
> 	+ t = p;
> 	+ do {
> 	+	 set_tsk_thread_flag(t, TIF_MEMDIE);
> 	+ } while_each_thread(p, t);
> 
> but this is matter of taste.
> 
Yes, this is better.

> Off-topic, but we shouldn't use force_sig(), SIGKILL doesn't
> need "force" semantics.
> 
This may need a dedicated patch, there are some other places to
force_sig(SIGKILL, ...) too.

> I'd wish I could understand the changelog ;)
> 
Assume thread A and B are in the same group.  If A runs into the oom,
and selects B as the victim, B won't exit because at least in exit_mm(),
it can not get the mm->mmap_sem semaphore which A has already got.  So
no memory is freed, and no other task will be selected to kill.

I formatted the patch for -mm tree as David suggested.


---
 mm/oom_kill.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -418,8 +418,15 @@ static void dump_header(struct task_stru
  */
 static void __oom_kill_task(struct task_struct *p)
 {
+	struct task_struct *t;
+
 	p->rt.time_slice = HZ;
-	set_tsk_thread_flag(p, TIF_MEMDIE);
+
+	t = p;
+	do {
+		set_tsk_thread_flag(t, TIF_MEMDIE);
+	} while_each_thread(p, t);
+
 	force_sig(SIGKILL, p);
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2010-05-04 23:56 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-04 23:51 [patch -mm] memcg: make oom killer a no-op when no killable task can be found David Rientjes
  -- strict thread matches above, loose matches on Subject: below --
2010-03-28 14:55 [PATCH] oom killer: break from infinite loop anfei
2010-03-28 16:28 ` Oleg Nesterov
2010-03-28 21:21   ` David Rientjes
2010-03-29 14:06     ` anfei
2010-03-29 20:01       ` David Rientjes
2010-03-30 14:29         ` anfei
2010-03-30 20:29           ` David Rientjes
2010-03-31  0:57             ` KAMEZAWA Hiroyuki
2010-03-31  6:07               ` David Rientjes
2010-03-31  6:13                 ` KAMEZAWA Hiroyuki
2010-03-31  6:30                   ` Balbir Singh
2010-03-31  6:32                     ` David Rientjes
2010-03-31  7:08                       ` [patch -mm] memcg: make oom killer a no-op when no killable task can be found David Rientjes
2010-03-31  7:08                         ` KAMEZAWA Hiroyuki
2010-03-31  8:04                         ` Balbir Singh
2010-03-31 10:38                           ` David Rientjes
2010-04-04 23:28                         ` David Rientjes
2010-04-05 21:30                           ` Andrew Morton
2010-04-05 22:40                             ` David Rientjes
2010-04-05 22:49                               ` Andrew Morton
2010-04-05 23:01                                 ` David Rientjes
2010-04-06 12:08                                   ` KOSAKI Motohiro
2010-04-06 21:47                                     ` David Rientjes
2010-04-07  0:20                                       ` KAMEZAWA Hiroyuki
2010-04-07 13:29                                         ` KOSAKI Motohiro
2010-04-08 18:05                                           ` David Rientjes
2010-04-21 19:17                                             ` Andrew Morton
2010-04-21 22:04                                               ` David Rientjes
2010-04-22  0:23                                                 ` KAMEZAWA Hiroyuki
2010-04-22  8:34                                                   ` David Rientjes
2010-04-22  7:23                                               ` Nick Piggin
2010-04-22  7:25                                                 ` KAMEZAWA Hiroyuki
2010-04-22 10:09                                                   ` Nick Piggin
2010-04-22 10:27                                                     ` KAMEZAWA Hiroyuki
2010-04-22 21:11                                                       ` David Rientjes
2010-04-22 10:28                                                     ` David Rientjes
2010-04-22 15:39                                                       ` Nick Piggin
2010-04-22 21:09                                                         ` David Rientjes
2010-05-04 23:55                                               ` David Rientjes
2010-04-08 17:36                                         ` David Rientjes

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