From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: mhocko@kernel.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, oleg@redhat.com,
rientjes@google.com, vdavydov@parallels.com
Subject: Re: [RFC PATCH 1/6] oom: keep mm of the killed task available
Date: Thu, 7 Jul 2016 20:48:46 +0900 [thread overview]
Message-ID: <201607072048.JBE13074.FSOJVHLOFFMOtQ@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20160707082431.GB5379@dhcp22.suse.cz>
Michal Hocko wrote:
> On Sun 03-07-16 11:45:34, Tetsuo Handa wrote:
> > Michal Hocko wrote:
> > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> > > index 7d0a275df822..4ea4a649822d 100644
> > > --- a/mm/oom_kill.c
> > > +++ b/mm/oom_kill.c
> > > @@ -286,16 +286,17 @@ enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
> > > * Don't allow any other task to have access to the reserves unless
> > > * the task has MMF_OOM_REAPED because chances that it would release
> > > * any memory is quite low.
> > > + * MMF_OOM_NOT_REAPABLE means that the oom_reaper backed off last time
> > > + * so let it try again.
> > > */
> > > if (!is_sysrq_oom(oc) && atomic_read(&task->signal->oom_victims)) {
> > > - struct task_struct *p = find_lock_task_mm(task);
> > > + struct mm_struct *mm = task->signal->oom_mm;
> > > enum oom_scan_t ret = OOM_SCAN_ABORT;
> > >
> > > - if (p) {
> > > - if (test_bit(MMF_OOM_REAPED, &p->mm->flags))
> > > - ret = OOM_SCAN_CONTINUE;
> > > - task_unlock(p);
> > > - }
> > > + if (test_bit(MMF_OOM_REAPED, &mm->flags))
> > > + ret = OOM_SCAN_CONTINUE;
> > > + else if (test_bit(MMF_OOM_NOT_REAPABLE, &mm->flags))
> > > + ret = OOM_SCAN_SELECT;
> >
> > I don't think this is useful.
>
> Well, to be honest me neither but changing the retry logic is not in
> scope of this patch. It just preserved the existing logic. I guess we
> can get rid of it but that deserves a separate patch. The retry was
> implemented to cover unlikely stalls when the lock is held but as this
> hasn't ever been observed in the real life I would agree to remove it to
> simplify the code (even though it is literally few lines of code). I was
> probably overcautious when adding the flag.
>
You mean reverting http://lkml.kernel.org/r/1466426628-15074-10-git-send-email-mhocko@kernel.org ?
If we hit a situation where MMF_OOM_NOT_REAPABLE is set, it means that that mm
was used by multiple threads and one of them is blocked. On the other hand,
since currently task_struct->oom_reaper_list is used, we can hit
(say, T1 and T2 and T3 are sharing the same mm)
(1) The T1's mm is queued to oom_reaper_list for the first time by T1.
(2) The OOM reaper finds that mm for the first time.
(3) The OOM reaper fails to hold mm->mmap_sem for read because T3 is blocked with that mm->mmap_sem held for write.
(4) The T2's mm (which is same with T1's mm) is queued to oom_reaper_list for the second time by T2.
(5) The OOM reaper still fails to hold mm->mmap_sem for read because T3 is blocked with that mm->mmap_sem held for write.
(6) The OOM reaper sets MMF_OOM_NOT_REAPABLE.
(7) That mm is dequeued from oom_reaper_list for the first time by the OOM reaper.
(8) The OOM reaper finds that mm for the second time.
(9) The OOM reaper still fails to hold mm->mmap_sem for read because T3 is blocked with that mm->mmap_sem held for write.
(10) The OOM reaper sets MMF_OOM_REAPED.
(11) That mm is dequeued from oom_reaper_list for the second time by the OOM reaper.
sequences. To me, MMF_OOM_NOT_REAPABLE alone is unlikely helpful.
If oom_mm_list list which chains mm_struct is used, at least we won't
concurrently queue same mm which is currently under OOM reaper's operation.
--
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-07-07 11:48 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-01 9:26 [RFC PATCH 0/6] fortify oom killer even more Michal Hocko
2016-07-01 9:26 ` [RFC PATCH 1/6] oom: keep mm of the killed task available Michal Hocko
2016-07-03 2:45 ` Tetsuo Handa
2016-07-07 8:24 ` Michal Hocko
2016-07-07 11:48 ` Tetsuo Handa [this message]
2016-07-07 13:32 ` Michal Hocko
2016-07-01 9:26 ` [RFC PATCH 2/6] oom, suspend: fix oom_killer_disable vs. pm suspend properly Michal Hocko
2016-07-01 9:26 ` [RFC PATCH 3/6] exit, oom: postpone exit_oom_victim to later Michal Hocko
2016-07-01 9:26 ` [RFC PATCH 4/6] oom, oom_reaper: consider mmget_not_zero as a failure Michal Hocko
2016-07-01 9:26 ` [RFC PATCH 5/6] vhost, mm: make sure that oom_reaper doesn't reap memory read by vhost Michal Hocko
2016-07-03 13:47 ` Oleg Nesterov
2016-07-03 14:09 ` Michael S. Tsirkin
2016-07-03 15:18 ` Oleg Nesterov
2016-07-03 15:30 ` Michael S. Tsirkin
2016-07-03 16:47 ` Oleg Nesterov
2016-07-03 21:17 ` Michael S. Tsirkin
2016-07-07 8:28 ` Michal Hocko
2016-07-07 15:38 ` Michael S. Tsirkin
2016-07-08 12:29 ` Oleg Nesterov
2016-07-11 14:14 ` Michal Hocko
2016-07-12 14:33 ` Oleg Nesterov
2016-07-07 8:42 ` Michal Hocko
2016-07-07 16:46 ` Oleg Nesterov
2016-07-07 8:39 ` Michal Hocko
2016-07-22 11:09 ` Michal Hocko
2016-07-01 9:26 ` [RFC PATCH 6/6] oom, oom_reaper: allow to reap mm shared by the kthreads 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=201607072048.JBE13074.FSOJVHLOFFMOtQ@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=oleg@redhat.com \
--cc=rientjes@google.com \
--cc=vdavydov@parallels.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