From: Michal Hocko <mhocko@kernel.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] mm,oom: Teach lockdep about oom_lock.
Date: Fri, 8 Mar 2019 12:58:02 +0100 [thread overview]
Message-ID: <20190308115802.GJ5232@dhcp22.suse.cz> (raw)
In-Reply-To: <20190308115413.GI5232@dhcp22.suse.cz>
On Fri 08-03-19 12:54:13, Michal Hocko wrote:
> [Cc Petr for the lockdep part - the patch is
> http://lkml.kernel.org/r/1552040522-9085-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp]
now for real.
> On Fri 08-03-19 20:29:46, Tetsuo Handa wrote:
> > On 2019/03/08 20:03, Michal Hocko wrote:
> > > On Fri 08-03-19 19:22:02, Tetsuo Handa wrote:
> > >> Since we are not allowed to depend on blocking memory allocations when
> > >> oom_lock is already held, teach lockdep to consider that blocking memory
> > >> allocations might wait for oom_lock at as early location as possible, and
> > >> teach lockdep to consider that oom_lock is held by mutex_lock() than by
> > >> mutex_trylock().
> > >
> > > I do not understand this. It is quite likely that we will have multiple
> > > allocations hitting this path while somebody else might hold the oom
> > > lock.
> >
> > The thread who succeeded to hold oom_lock must not involve blocking memory
> > allocations. It is explained in the comment before get_page_from_freelist().
>
> Yes this is correct.
>
> > > What kind of problem does this actually want to prevent? Could you be
> > > more specific please?
> >
> > e.g.
> >
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -3688,6 +3688,7 @@ void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
> > * attempt shall not depend on __GFP_DIRECT_RECLAIM && !__GFP_NORETRY
> > * allocation which will never fail due to oom_lock already held.
> > */
> > + kfree(kmalloc(PAGE_SIZE, GFP_NOIO));
> > page = get_page_from_freelist((gfp_mask | __GFP_HARDWALL) &
> > ~__GFP_DIRECT_RECLAIM, order,
> > ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac);
> >
> >
> > Since https://lore.kernel.org/lkml/20190308013134.GB4063@jagdpanzerIV/T/#u made me
> > worry that we might by error introduce such dependency in near future, I propose
> > this change as a proactive protection.
>
> OK, that makes sense to me. I cannot judge the implementation because I
> am not really familiar with lockdep machinery. Could you explain how it
> doesn't trigger for all other allocations?
>
> Also why it is not sufficient to add the lockdep annotation prior to the
> trylock in __alloc_pages_may_oom?
>
> --
> Michal Hocko
> SUSE Labs
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-03-08 11:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 10:22 Tetsuo Handa
2019-03-08 11:03 ` Michal Hocko
2019-03-08 11:29 ` Tetsuo Handa
2019-03-08 11:54 ` Michal Hocko
2019-03-08 11:58 ` Michal Hocko [this message]
2019-03-08 15:01 ` Peter Zijlstra
2019-03-08 15:13 ` Michal Hocko
2019-03-09 6:02 ` Tetsuo Handa
2019-03-11 10:30 ` Michal Hocko
2019-03-12 14:06 ` Tetsuo Handa
2019-03-12 15:31 ` Michal Hocko
2019-03-14 13:55 ` Tetsuo Handa
2019-03-12 8:24 ` Peter Zijlstra
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=20190308115802.GJ5232@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=peterz@infradead.org \
/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