From: Michal Hocko <mhocko@suse.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: hannes@cmpxchg.org, aarcange@redhat.com,
akpm@linux-foundation.org, linux-mm@kvack.org,
rientjes@google.com, mjaggi@caviumnetworks.com, mgorman@suse.de,
oleg@redhat.com, vdavydov.dev@gmail.com, vbabka@suse.cz
Subject: Re: [RFC PATCH 2/2] mm,oom: Try last second allocation after selecting an OOM victim.
Date: Wed, 25 Oct 2017 17:05:49 +0200 [thread overview]
Message-ID: <20171025150548.nvuwc3y3m5vi23uk@dhcp22.suse.cz> (raw)
In-Reply-To: <201710252358.IIA46427.HFFSOOOQLtFMJV@I-love.SAKURA.ne.jp>
On Wed 25-10-17 23:58:33, Tetsuo Handa wrote:
> Michal Hocko wrote:
> > On Wed 25-10-17 21:15:24, Tetsuo Handa wrote:
> > > Michal Hocko wrote:
> > > > On Wed 25-10-17 19:48:09, Tetsuo Handa wrote:
> > > > > Michal Hocko wrote:
> > > > [...]
> > > > > > The OOM killer is the last hand break. At the time you hit the OOM
> > > > > > condition your system is usually hard to use anyway. And that is why I
> > > > > > do care to make this path deadlock free. I have mentioned multiple times
> > > > > > that I find real life triggers much more important than artificial DoS
> > > > > > like workloads which make your system unsuable long before you hit OOM
> > > > > > killer.
> > > > >
> > > > > Unable to invoke the OOM killer (i.e. OOM lockup) is worse than hand break injury.
> > > > >
> > > > > If you do care to make this path deadlock free, you had better stop depending on
> > > > > mutex_trylock(&oom_lock). Not only printk() from oom_kill_process() can trigger
> > > > > deadlock due to console_sem versus oom_lock dependency but also
> > > >
> > > > And this means that we have to fix printk. Completely silent oom path is
> > > > out of question IMHO
> > >
> > > We cannot fix printk() without giving enough CPU resource to printk().
> >
> > This is a separate discussion but having a basically unbound time spent
> > in printk is simply a no-go.
> >
> > > I don't think "Completely silent oom path" can happen, for warn_alloc() is called
> > > again when it is retried. But anyway, let's remove warn_alloc().
> >
> > I mean something else. We simply cannot do the oom killing without
> > telling userspace about that. And printk is the only API we can use for
> > that.
>
> I thought something like
>
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3872,6 +3872,7 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask)
> unsigned int stall_timeout = 10 * HZ;
> unsigned int cpuset_mems_cookie;
> int reserve_flags;
> + static DEFINE_MUTEX(warn_lock);
>
> /*
> * In the slowpath, we sanity check order to avoid ever trying to
> @@ -4002,11 +4003,15 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask)
> goto nopage;
>
> /* Make sure we know about allocations which stall for too long */
> - if (time_after(jiffies, alloc_start + stall_timeout)) {
> - warn_alloc(gfp_mask & ~__GFP_NOWARN, ac->nodemask,
> - "page allocation stalls for %ums, order:%u",
> - jiffies_to_msecs(jiffies-alloc_start), order);
> - stall_timeout += 10 * HZ;
> + if (time_after(jiffies, alloc_start + stall_timeout) &&
> + mutex_trylock(&warn_lock)) {
> + if (!mutex_is_locked(&oom_lock)) {
The check for oom_lock just doesn't make any sense. The lock can be take
at any time after the check.
> + warn_alloc(gfp_mask & ~__GFP_NOWARN, ac->nodemask,
> + "page allocation stalls for %ums, order:%u",
> + jiffies_to_msecs(jiffies-alloc_start), order);
> + stall_timeout += 10 * HZ;
> + }
> + mutex_unlock(&warn_lock);
> }
>
> /* Avoid recursion of direct reclaim */
>
> for isolating the OOM killer messages and the stall warning messages (in order to
> break continuation condition in console_unlock()), and
>
> @@ -3294,7 +3294,7 @@ void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
> * Acquire the oom lock. If that fails, somebody else is
> * making progress for us.
> */
> - if (!mutex_trylock(&oom_lock)) {
> + if (mutex_lock_killable(&oom_lock)) {
> *did_some_progress = 1;
> schedule_timeout_uninterruptible(1);
> return NULL;
>
> for giving printk() enough CPU resource.
>
> What you thought is avoid using printk() from out_of_memory() in case enough
> CPU resource is not given, isn't it? Then, that is out of question.
No I meant that we simply _have to_ use printk from the OOM killer.
--
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>
next prev parent reply other threads:[~2017-10-25 15:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1503577106-9196-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>
2017-08-24 12:18 ` Tetsuo Handa
2017-08-24 13:18 ` Michal Hocko
2017-08-24 14:40 ` Tetsuo Handa
2017-08-25 8:00 ` Michal Hocko
2017-09-09 0:55 ` Tetsuo Handa
[not found] ` <201710172204.AGG30740.tVHJFFOQLMSFOO@I-love.SAKURA.ne.jp>
2017-10-20 12:40 ` Michal Hocko
2017-10-20 14:18 ` Tetsuo Handa
2017-10-23 11:30 ` Michal Hocko
2017-10-24 11:24 ` Tetsuo Handa
2017-10-24 11:41 ` Michal Hocko
2017-10-25 10:48 ` Tetsuo Handa
2017-10-25 11:09 ` Michal Hocko
2017-10-25 12:15 ` Tetsuo Handa
2017-10-25 12:41 ` Michal Hocko
2017-10-25 14:58 ` Tetsuo Handa
2017-10-25 15:05 ` Michal Hocko [this message]
2017-10-25 15:34 ` Tetsuo Handa
2017-08-24 13:03 ` [PATCH 1/2] mm,page_alloc: Don't call __node_reclaim() with oom_lock held Michal Hocko
2017-08-25 20:47 ` Andrew Morton
2017-08-26 1:28 ` Tetsuo Handa
2017-08-27 4:17 ` Tetsuo Handa
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=20171025150548.nvuwc3y3m5vi23uk@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mjaggi@caviumnetworks.com \
--cc=oleg@redhat.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
--cc=vdavydov.dev@gmail.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