From: Oleg Nesterov <oleg@redhat.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
linux-mm@kvack.org, vdavydov@virtuozzo.com, rientjes@google.com
Subject: Re: [PATCH] mm,oom: use per signal_struct flag rather than clear TIF_MEMDIE
Date: Wed, 29 Jun 2016 02:13:53 +0200 [thread overview]
Message-ID: <20160629001353.GA9377@redhat.com> (raw)
In-Reply-To: <20160628101956.GA510@dhcp22.suse.cz>
Michal,
I am already sleeping, I'll try to reply to other parts of your email
(and other emails) tomorrow, just some notes about the patch you propose.
And cough sorry for noise... I personally hate-hate-hate every new "oom"
member you and Tetsuo add into task/signal_struct ;) But not in this case,
because I _think_ we need signal_struct->mm anyway in the long term.
So at first glance this patch makes sense, but unless I missed something
(the patch doesn't apply I can be easily wrong),
On 06/28, Michal Hocko wrote:
>
> @@ -245,6 +245,8 @@ static inline void free_signal_struct(struct signal_struct *sig)
> {
> taskstats_tgid_free(sig);
> sched_autogroup_exit(sig);
> + if (sig->oom_mm)
> + mmdrop(sig->oom_mm);
> kmem_cache_free(signal_cachep, sig);
> }
OK, iiuc this is not that bad because only oom-killer can set it,
> +void mark_oom_victim(struct task_struct *tsk, struct mm_struct *mm)
> {
> WARN_ON(oom_killer_disabled);
> /* OOM killer might race with memcg OOM */
> if (test_and_set_tsk_thread_flag(tsk, TIF_MEMDIE))
> return;
> +
> atomic_inc(&tsk->signal->oom_victims);
> +
> + /* oom_mm is bound to the signal struct life time */
> + if (!tsk->signal->oom_mm) {
> + atomic_inc(&mm->mm_count);
> + tsk->signal->oom_mm = mm;
Looks racy, but it is not because we rely on oom_lock? Perhaps a comment
makes sense.
> @@ -828,7 +816,7 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
> struct task_struct *victim = p;
> struct task_struct *child;
> struct task_struct *t;
> - struct mm_struct *mm;
> + struct mm_struct *mm = READ_ONCE(p->mm);
> unsigned int victim_points = 0;
> static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
> DEFAULT_RATELIMIT_BURST);
> @@ -838,8 +826,8 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
> * If the task is already exiting, don't alarm the sysadmin or kill
> * its children or threads, just set TIF_MEMDIE so it can die quickly
> */
> - if (task_will_free_mem(p)) {
> - mark_oom_victim(p);
> + if (mm && task_will_free_mem(p)) {
> + mark_oom_victim(p, mm);
And this looks really racy at first glance. Suppose that this memory hog execs
(this changes its ->mm) and then exits so that task_will_free_mem() == T, in
this case "mm" has nothing to do with tsk->mm and it can be already freed.
Oleg.
--
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:[~2016-06-29 0:13 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 11:02 [PATCH] mm,oom: use per signal_struct flag rather than clear TIF_MEMDIE Tetsuo Handa
2016-06-24 12:39 ` Michal Hocko
2016-06-24 15:54 ` Tetsuo Handa
2016-06-24 22:42 ` Oleg Nesterov
2016-06-24 21:56 ` Oleg Nesterov
2016-06-25 5:44 ` Tetsuo Handa
2016-06-27 9:23 ` Michal Hocko
2016-06-27 10:36 ` Michal Hocko
2016-06-27 15:51 ` Oleg Nesterov
2016-06-27 16:06 ` Michal Hocko
2016-06-27 17:55 ` Oleg Nesterov
2016-06-28 10:19 ` Michal Hocko
2016-06-29 0:13 ` Oleg Nesterov [this message]
2016-06-29 8:33 ` Michal Hocko
2016-06-29 14:19 ` Michal Hocko
2016-07-01 10:15 ` Tetsuo Handa
2016-06-29 20:01 ` Oleg Nesterov
2016-06-30 7:59 ` Michal Hocko
2016-06-30 10:51 ` Tetsuo Handa
2016-06-30 11:21 ` Michal Hocko
2016-07-03 13:32 ` Oleg Nesterov
2016-07-03 13:21 ` Oleg Nesterov
2016-07-07 11:51 ` Michal Hocko
2016-07-07 16:42 ` Oleg Nesterov
2016-06-29 20:14 ` Oleg Nesterov
2016-06-30 8:07 ` Michal Hocko
2016-07-03 13:24 ` Oleg Nesterov
2016-06-27 21:09 ` Oleg Nesterov
2016-06-28 10:26 ` Michal Hocko
2016-06-29 19:34 ` Oleg Nesterov
2016-06-27 20:40 ` Oleg Nesterov
2016-06-28 10:29 ` Michal Hocko
2016-06-29 20:24 ` Oleg Nesterov
2016-06-30 8:16 ` 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=20160629001353.GA9377@redhat.com \
--to=oleg@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--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).