linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH] mm, oom: check memcg margin for parallel oom
Date: Tue, 14 Jul 2020 15:34:53 +0200	[thread overview]
Message-ID: <20200714133453.GM24642@dhcp22.suse.cz> (raw)
In-Reply-To: <CALOAHbBZuvVNnYS1=KkLH4kioVAoFDeqJMe_hkfZ2dkPnWR7Kw@mail.gmail.com>

On Tue 14-07-20 21:25:04, Yafang Shao wrote:
> On Tue, Jul 14, 2020 at 8:37 PM Michal Hocko <mhocko@kernel.org> wrote:
[...]
> > > @@ -1560,16 +1560,31 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
> > >               .gfp_mask = gfp_mask,
> > >               .order = order,
> > >       };
> > > -     bool ret;
> > > +     bool ret = true;
> > >
> > >       if (mutex_lock_killable(&oom_lock))
> > >               return true;
> > > +
> > >       /*
> > >        * A few threads which were not waiting at mutex_lock_killable() can
> > >        * fail to bail out. Therefore, check again after holding oom_lock.
> > >        */
> > > -     ret = should_force_charge() || out_of_memory(&oc);
> > > +     if (should_force_charge())
> > > +             goto out;
> > > +
> > > +     /*
> > > +      * Different tasks may be doing parallel oom, so after hold the
> > > +      * oom_lock the task should check the memcg margin again to check
> > > +      * whether other task has already made progress.
> > > +      */
> > > +     if (mem_cgroup_margin(memcg) >= (1 << order))
> > > +             goto out;
> >
> > Is there any reason why you simply haven't done this? (+ your comment
> > which is helpful).
> >
> 
> No strong reason.
> I just think that threads of a multi-thread task are more likely to do
> parallel OOM, so I checked it first.
> I can change it as you suggested below,  as it is more simple.

I would rather go with simplicity. This is a super slow path so ordering
of checks shouldn't matter much (if at all).

-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2020-07-14 13:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 12:08 Yafang Shao
2020-07-14 12:37 ` Michal Hocko
2020-07-14 12:38   ` Michal Hocko
2020-07-14 13:26     ` Yafang Shao
2020-07-14 12:47   ` Tetsuo Handa
2020-07-14 12:57     ` Michal Hocko
2020-07-14 13:25   ` Yafang Shao
2020-07-14 13:34     ` Michal Hocko [this message]
2020-07-14 13:40       ` Yafang Shao

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=20200714133453.GM24642@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --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