From: Michal Hocko <mhocko@suse.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chunyu Hu <chuhu@redhat.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
malat@debian.org, dvyukov@google.com, linux-mm@kvack.org,
Akinobu Mita <akinobu.mita@gmail.com>
Subject: Re: [PATCH] kmemleak: don't use __GFP_NOFAIL
Date: Thu, 31 May 2018 20:41:04 +0200 [thread overview]
Message-ID: <20180531184104.GT15278@dhcp22.suse.cz> (raw)
In-Reply-To: <20180531152225.2ck6ach4lma4zeim@armageddon.cambridge.arm.com>
On Thu 31-05-18 16:22:26, Catalin Marinas wrote:
> Hi Michal,
>
> I'm catching up with this thread.
>
> On Wed, May 30, 2018 at 02:38:26PM +0200, Michal Hocko wrote:
> > On Wed 30-05-18 07:42:59, Chunyu Hu wrote:
> > > From: "Michal Hocko" <mhocko@suse.com>
> > > > want to have a pre-populated pool of objects for those requests. The
> > > > obvious question is how to balance such a pool. It ain't easy to track
> > > > memory by allocating more memory...
> > >
> > > This solution is going to make kmemleak trace really nofail. We can think
> > > later.
> > >
> > > while I'm thinking about if fault inject can be disabled via flag in task.
> > >
> > > Actually, I'm doing something like below, the disable_fault_inject() is
> > > just setting a flag in task->make_it_fail. But this will depend on if
> > > fault injection accept a change like this. CCing Akinobu
> >
> > You still seem to be missing my point I am afraid (or I am ;). So say
> > that you want to track a GFP_NOWAIT allocation request. So create_object
> > will get called with that gfp mask and no matter what you try here your
> > tracking object will be allocated in a weak allocation context as well
> > and disable kmemleak. So it only takes a more heavy memory pressure and
> > the tracing is gone...
>
> create_object() indeed gets the originating gfp but it only cares
> whether it was GFP_KERNEL or GFP_ATOMIC. gfp_kmemleak_mask() masks out
> all the other flags when allocating a struct kmemleak_object (and adds
> some of its own).
>
> This has worked ok so far. There is a higher risk of GFP_ATOMIC
> allocations failing but I haven't seen issues with kmemleak unless you
> run it under heavy memory pressure (and kmemleak just disables itself).
> With fault injection, such pressure is simulated with the side effect of
> rendering kmemleak unusable.
>
> Kmemleak could implement its own allocation mechanism (maybe even
> skipping the slab altogether) but I feel it's overkill just to cope with
> the specific case of fault injection. Also, it's not easy to figure out
> how to balance such pool and it may end up calling alloc_pages() which
> in turn can inject a fault.
>
> Could we tweak gfp_kmemleak_mask() to still pass __GFP_NOFAIL but in a
> compatible way (e.g. by setting __GFP_DIRECT_RECLAIM) when fault
> injection is enabled?
>
> Otherwise, I'd prefer some per-thread temporary fault injection
> disabling.
Well, there are two issues (which boil down to the one in the end) here.
Fault injection or a GFP_NOWAIT or any other weaker than GFP_KERNEL
context is something to care about. A weaker allocation context can and
will lead to kmemleak meta data allocation failures regardless of the
fault injection. The way how those objects are allocated directly in the
allacator context makes this really hard and inherently subtle. I can
see only two ways around. Either you have a placeholder for "this object
is not tracked so do not throw false positives" or have a preallocated
pool to use if the direct context allocation failes for whatever reason.
Abusing __GFP_NOFAIL is simply a crude hack which will lead to all kind
of problems.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2018-05-31 18:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-26 7:14 WARNING: CPU: 0 PID: 21 at ../mm/page_alloc.c:4258 __alloc_pages_nodemask+0xa88/0xfec Mathieu Malaterre
2018-05-28 8:34 ` Michal Hocko
2018-05-28 13:05 ` [PATCH] kmemleak: don't use __GFP_NOFAIL Tetsuo Handa
2018-05-28 13:24 ` Michal Hocko
2018-05-28 21:05 ` Tetsuo Handa
2018-05-29 13:27 ` Chunyu Hu
2018-05-29 13:46 ` Tetsuo Handa
2018-05-30 9:35 ` Chunyu Hu
2018-05-30 10:46 ` Michal Hocko
2018-05-30 11:42 ` Chunyu Hu
2018-05-30 12:38 ` Michal Hocko
2018-05-31 10:51 ` Chunyu Hu
2018-05-31 11:35 ` Michal Hocko
2018-05-31 12:28 ` Chunyu Hu
2018-05-31 15:22 ` Catalin Marinas
2018-05-31 18:41 ` Michal Hocko [this message]
2018-06-01 1:50 ` Chunyu Hu
2018-06-01 4:53 ` Chunyu Hu
2018-06-04 8:41 ` Dmitry Vyukov
2018-06-04 12:42 ` Michal Hocko
2018-06-04 15:08 ` Catalin Marinas
2018-06-04 15:36 ` Dmitry Vyukov
2018-06-04 16:41 ` Catalin Marinas
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=20180531184104.GT15278@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akinobu.mita@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=chuhu@redhat.com \
--cc=dvyukov@google.com \
--cc=linux-mm@kvack.org \
--cc=malat@debian.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/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