linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] oom: split out forced OOM killer
Date: Fri, 19 Jun 2015 09:13:09 +0200	[thread overview]
Message-ID: <20150619071309.GB4913@dhcp22.suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.10.1506181222010.3668@chino.kir.corp.google.com>

On Thu 18-06-15 12:27:12, David Rientjes wrote:
> On Thu, 18 Jun 2015, Michal Hocko wrote:
> 
> > The forced OOM killing is currently wired into out_of_memory() call
> > even though their objective is different which makes the code ugly
> > and harder to follow. Generic out_of_memory path has to deal with
> > configuration settings and heuristics which are completely irrelevant
> > to the forced OOM killer (e.g. sysctl_oom_kill_allocating_task or
> > OOM killer prevention for already dying tasks). All of them are
> > either relying on explicit force_kill check or indirectly by checking
> > current->mm which is always NULL for sysrq+f. This is not nice, hard
> > to follow and error prone.
> > 
> > Let's pull forced OOM killer code out into a separate function
> > (force_out_of_memory) which is really trivial now.
> > As a bonus we can clearly state that this is a forced OOM killer
> > in the OOM message which is helpful to distinguish it from the
> > regular OOM killer.
> > 
> 
> Ok, so this patch reverts _everything_ in the first patch other than the 
> documentation.  Just start with this patch instead, sheesh.

The ordering is intentional. Clean up on top of the fix. And considering
how much you "loved" the previous attempt of the cleanup I had even
stronger reason to put this on top of the fix.

> > Signed-off-by: Michal Hocko <mhocko@suse.cz>
> > ---
> >  drivers/tty/sysrq.c |  3 +--
> >  include/linux/oom.h |  3 ++-
> >  mm/oom_kill.c       | 57 ++++++++++++++++++++++++++++++++---------------------
> >  mm/page_alloc.c     |  2 +-
> >  4 files changed, 39 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> > index 3a42b7187b8e..06a95a8ed701 100644
> > --- a/drivers/tty/sysrq.c
> > +++ b/drivers/tty/sysrq.c
> > @@ -356,8 +356,7 @@ static struct sysrq_key_op sysrq_term_op = {
> >  static void moom_callback(struct work_struct *ignored)
> >  {
> >  	mutex_lock(&oom_lock);
> > -	if (!out_of_memory(node_zonelist(first_memory_node, GFP_KERNEL),
> > -			   GFP_KERNEL, 0, NULL, true))
> > +	if (!force_out_of_memory())
> >  		pr_info("OOM request ignored because killer is disabled\n");
> >  	mutex_unlock(&oom_lock);
> >  }
> > diff --git a/include/linux/oom.h b/include/linux/oom.h
> > index 7deecb7bca5e..061e0ffd3493 100644
> > --- a/include/linux/oom.h
> > +++ b/include/linux/oom.h
> > @@ -70,8 +70,9 @@ extern enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
> >  		unsigned long totalpages, const nodemask_t *nodemask,
> >  		bool force_kill);
> >  
> > +extern bool force_out_of_memory(void);
> >  extern bool out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
> > -		int order, nodemask_t *mask, bool force_kill);
> > +		int order, nodemask_t *mask);
> >  
> >  extern void exit_oom_victim(void);
> >  
> > diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> > index 0c312eaac834..050936f35944 100644
> > --- a/mm/oom_kill.c
> > +++ b/mm/oom_kill.c
> > @@ -635,12 +635,38 @@ int unregister_oom_notifier(struct notifier_block *nb)
> >  EXPORT_SYMBOL_GPL(unregister_oom_notifier);
> >  
> >  /**
> > - * __out_of_memory - kill the "best" process when we run out of memory
> > + * force_out_of_memory - forces OOM killer
> 
> ... to kill a process.

OK
 
> > + *
> > + * External trigger for the OOM killer. The system doesn't have to be under
> > + * OOM condition (e.g. sysrq+f).
> > + */
> 
> I'm still not sure what you mean by external.  I assume you're referring 
> to induced by userspace rather than the kernel.  I think you should use 
> the word "explicit".

OK
---
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5af8b5e44b27..7783a3760c56 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -635,9 +635,9 @@ int unregister_oom_notifier(struct notifier_block *nb)
 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
 
 /**
- * force_out_of_memory - forces OOM killer
+ * force_out_of_memory - forces OOM killer to kill a process
  *
- * External trigger for the OOM killer. The system doesn't have to be under
+ * Explicitly trigger the OOM killer. The system doesn't have to be under
  * OOM condition (e.g. sysrq+f).
  */
 bool force_out_of_memory(void)
-- 
Michal Hocko
SUSE Labs

--
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:[~2015-06-19  7:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  9:57 [PATCH 0/2] oom: sysrq+f shouldn't not panic the system + cleanup Michal Hocko
2015-06-18  9:57 ` [PATCH 1/2] oom: Do not panic when OOM killer is sysrq triggered Michal Hocko
2015-06-18 19:21   ` David Rientjes
2015-06-19  7:09     ` Michal Hocko
2015-06-18  9:57 ` [PATCH 2/2] oom: split out forced OOM killer Michal Hocko
2015-06-18 19:27   ` David Rientjes
2015-06-19  7:13     ` Michal Hocko [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=20150619071309.GB4913@dhcp22.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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