From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-mm@kvack.org, David Rientjes <rientjes@google.com>,
Manish Jaggi <mjaggi@caviumnetworks.com>,
Michal Hocko <mhocko@suse.com>, Oleg Nesterov <oleg@redhat.com>,
Vladimir Davydov <vdavydov@virtuozzo.com>
Subject: Re: [PATCH] mm, oom: task_will_free_mem(current) should ignore MMF_OOM_SKIP for once.
Date: Wed, 2 Aug 2017 17:04:09 -0700 [thread overview]
Message-ID: <20170802170409.caaaab2a866cf8ac210291cc@linux-foundation.org> (raw)
In-Reply-To: <1501718104-8099-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>
On Thu, 3 Aug 2017 08:55:04 +0900 Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> Manish Jaggi noticed that running LTP oom01/oom02 ltp tests with high core
> count causes random kernel panics when an OOM victim which consumed memory
> in a way the OOM reaper does not help was selected by the OOM killer.
>
> ...
>
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -652,6 +652,7 @@ struct task_struct {
> /* disallow userland-initiated cgroup migration */
> unsigned no_cgroup_migration:1;
> #endif
> + unsigned oom_kill_free_check_raced:1;
>
> unsigned long atomic_flags; /* Flags requiring atomic access. */
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 9e8b4f0..a1ae78d 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -780,11 +780,19 @@ static bool task_will_free_mem(struct task_struct *task)
> return false;
>
> /*
> - * This task has already been drained by the oom reaper so there are
> - * only small chances it will free some more
> + * It is possible that current thread fails to try allocation from
> + * memory reserves if the OOM reaper set MMF_OOM_SKIP on this mm before
> + * current thread calls out_of_memory() in order to get TIF_MEMDIE.
> + * In that case, allow current thread to try TIF_MEMDIE allocation
> + * before start selecting next OOM victims.
> */
> - if (test_bit(MMF_OOM_SKIP, &mm->flags))
> + if (test_bit(MMF_OOM_SKIP, &mm->flags)) {
> + if (task == current && !task->oom_kill_free_check_raced) {
> + task->oom_kill_free_check_raced = true;
OK, caller's task_lock() prevents races here.
nit: task->oom_kill_free_check_raced is `unsigned', so " = 1" would be
more truthful here...
> + return true;
> + }
> return false;
> + }
>
> if (atomic_read(&mm->mm_users) <= 1)
> return true;
--
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-08-03 0:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 23:55 [PATCH] mm, oom: task_will_free_mem(current) should ignore MMF_OOM_SKIP for once Tetsuo Handa
2017-08-03 0:04 ` Andrew Morton [this message]
2017-08-03 7:10 ` Michal Hocko
2017-08-03 7:53 ` Tetsuo Handa
2017-08-03 8:14 ` Michal Hocko
2017-08-04 11:10 ` Tetsuo Handa
2017-08-04 11:26 ` Michal Hocko
2017-08-04 11:44 ` Tetsuo Handa
2017-08-04 11:52 ` Michal Hocko
2017-08-04 11:54 ` Manish Jaggi
2017-08-04 15:24 ` Tetsuo Handa
2017-08-04 15:54 ` Tetsuo Handa
2017-08-19 6:23 ` [PATCH v2] " Tetsuo Handa
2017-08-21 8:43 ` Michal Hocko
2017-08-21 11:41 ` Tetsuo Handa
2017-08-21 12:10 ` Michal Hocko
2017-08-21 12:57 ` Tetsuo Handa
2017-08-21 13:18 ` Michal Hocko
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=20170802170409.caaaab2a866cf8ac210291cc@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mjaggi@caviumnetworks.com \
--cc=oleg@redhat.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rientjes@google.com \
--cc=vdavydov@virtuozzo.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).