linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan.kim@gmail.com>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Nick Piggin <npiggin@suse.de>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH -mm] Kill existing current task quickly
Date: Wed, 17 Feb 2010 19:55:14 +0900	[thread overview]
Message-ID: <1266404114.1709.75.camel@barrios-desktop> (raw)
In-Reply-To: <alpine.DEB.2.00.1002170128230.30931@chino.kir.corp.google.com>

On Wed, 2010-02-17 at 01:36 -0800, David Rientjes wrote:
> On Wed, 17 Feb 2010, Minchan Kim wrote:
> 
> > diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> > index 3618be3..d5e3d70 100644
> > --- a/mm/oom_kill.c
> > +++ b/mm/oom_kill.c
> > @@ -32,6 +32,8 @@ int sysctl_panic_on_oom;
> >  int sysctl_oom_kill_allocating_task;
> >  int sysctl_oom_dump_tasks;
> >  static DEFINE_SPINLOCK(zone_scan_lock);
> > +
> > +unsigned int nr_memdie; /* count of TIF_MEMDIE processes */
> >  /* #define DEBUG */
> > 
> >  /*
> > @@ -295,6 +297,8 @@ static struct task_struct
> > *select_bad_process(unsigned long *ppoints,
> > 
> >                         chosen = p;
> >                         *ppoints = ULONG_MAX;
> > +                       if (nr_memdie == 0)
> > +                               break;
> >                 }
> > 
> >                 if (p->signal->oom_adj == OOM_DISABLE)
> 
> Nack, finding a candidate task with TIF_MEMDIE set is not the only time we 
> return ERR_PTR(-1UL) from select_bad_process(): we also do it if any other 
> task other than current is PF_EXITING.  Thus, we _must_ continue the 
> tasklist scan to avoid needlessly killing current simply because it was 
> the first PF_EXITING task in the tasklist.

Okay. Sorry for missing PF_EXITING tasks. 

> 
> > @@ -403,8 +407,6 @@ static void __oom_kill_task(struct task_struct *p,
> > int verbose)
> >                        K(p->mm->total_vm),
> >                        K(get_mm_counter(p->mm, MM_ANONPAGES)),
> >                        K(get_mm_counter(p->mm, MM_FILEPAGES)));
> > -       task_unlock(p);
> > -
> >         /*
> >          * We give our sacrificial lamb high priority and access to
> >          * all the memory it needs. That way it should be able to
> > @@ -412,7 +414,11 @@ static void __oom_kill_task(struct task_struct
> > *p, int verbose)
> >          */
> >         p->rt.time_slice = HZ;
> >         set_tsk_thread_flag(p, TIF_MEMDIE);
> > -
> > +       /*
> > +        * nr_memdie is protected by task_lock.
> > +        */
> > +       nr_memdie++;
> > +       task_unlock(p);
> >         force_sig(SIGKILL, p);
> >  }
> > 
> 
> task_lock() is a per-task entity, i.e. each task_struct has an alloc_lock 
> spinlock.  This cannot protect a global variable.

Yes. It was utterly dumb lock usage. 
Thanks for the quick reply. 
 

-- 
Kind regards,
Minchan Kim


--
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>

      reply	other threads:[~2010-02-17 10:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-16 15:59 [PATCH -mm] Kill existing current task quickly Minchan Kim
2010-02-16 22:03 ` David Rientjes
2010-02-17  6:26   ` Minchan Kim
2010-02-17  9:36     ` David Rientjes
2010-02-17 10:55       ` Minchan Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266404114.1709.75.camel@barrios-desktop \
    --to=minchan.kim@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@suse.de \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).