From: Michal Hocko <mhocko@suse.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: NeilBrown <neilb@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Uladzislau Rezki <urezki@gmail.com>,
Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@lst.de>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
LKML <linux-kernel@vger.kernel.org>,
Ilya Dryomov <idryomov@gmail.com>,
Jeff Layton <jlayton@kernel.org>
Subject: Re: [PATCH v2 2/4] mm/vmalloc: add support for __GFP_NOFAIL
Date: Fri, 26 Nov 2021 16:09:40 +0100 [thread overview]
Message-ID: <YaD4tFV1P4vwBVEL@dhcp22.suse.cz> (raw)
In-Reply-To: <919f547e-beb7-34b7-7835-9e1625600323@suse.cz>
On Fri 26-11-21 15:50:15, Vlastimil Babka wrote:
> On 11/24/21 06:23, NeilBrown wrote:
> >>
> >> I forget why radix_tree_preload used a cpu-local store rather than a
> >> per-task one.
> >>
> >> Plus "what order pages would you like" and "on which node" and "in
> >> which zone", etc...
> >
> > "what order" - only order-0 I hope. I'd hazard a guess that 90% of
> > current NOFAIL allocations only need one page (providing slub is used -
> > slab seems to insist on high-order pages sometimes).
>
> Yeah AFAIK SLUB can prefer higher orders than SLAB, but also allows fallback
> to smallest order that's enough (thus 0 unless the objects are larger than a
> page).
>
> > "which node" - whichever. Unless __GFP_HARDWALL is set, alloc_page()
> > will fall-back to "whichever" anyway, and NOFAIL with HARDWALL is
> > probably a poor choice.
> > "which zone" - NORMAL. I cannot find any NOFAIL allocations that want
> > DMA. fs/ntfs asks for __GFP_HIGHMEM with NOFAIL, but that that doesn't
> > *requre* highmem.
> >
> > Of course, before designing this interface too precisely we should check
> > if anyone can use it. From a quick through the some of the 100-ish
> > users of __GFP_NOFAIL I'd guess that mempools would help - the
> > preallocation should happen at init-time, not request-time. Maybe if we
> > made mempools even more light weight .... though that risks allocating a
> > lot of memory that will never get used.
> >
> > This brings me back to the idea that
> > alloc_page(wait and reclaim allowed)
> > should only fail on OOM_KILL. That way kernel threads are safe, and
> > user-threads are free to return ENOMEM knowing it won't get to
>
> Hm I thought that's already pretty much the case of the "too small to fail"
> of today. IIRC there's exactly that gotcha that OOM KILL can result in such
> allocation failure. But I believe that approach is rather fragile. If you
> encounter such an allocation not checking the resulting page != NULL, you
> can only guess which one is true:
>
> - the author simply forgot to check at all
> - the author relied on "too small to fail" without realizing the gotcha
> - at the time of writing the code was verified that it can be only run in
> kernel thread context, not user and
> - it is still true
> - it stopped being true at some later point
> - might be hard to even decide which is the case
>
> IIRC at some point we tried to abolish the "too small to fail" rule because
> of this, but Linus denied that. But the opposite - make it hard guarantee in
> all cases - also didn't happen, so...
Yeah. IMHO we should treat each missing check for allocation failure
(except for GFP_NOFAIL) as a bug regardless the practical implementation
that say that small allocations do not fail. Because they can fail and
we should never subscribe to official support implicit non-fail
semantic.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2021-11-26 15:10 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 15:32 [PATCH v2 0/4] extend vmalloc support for constrained allocations Michal Hocko
2021-11-22 15:32 ` [PATCH v2 1/4] mm/vmalloc: alloc GFP_NO{FS,IO} for vmalloc Michal Hocko
2021-11-23 19:05 ` Uladzislau Rezki
2021-11-26 15:13 ` Vlastimil Babka
2021-11-22 15:32 ` [PATCH v2 2/4] mm/vmalloc: add support for __GFP_NOFAIL Michal Hocko
2021-11-23 19:01 ` Uladzislau Rezki
2021-11-23 20:09 ` Michal Hocko
2021-11-24 20:46 ` Uladzislau Rezki
2021-11-24 1:02 ` Andrew Morton
2021-11-24 3:16 ` NeilBrown
2021-11-24 3:48 ` Andrew Morton
2021-11-24 5:23 ` NeilBrown
2021-11-25 0:32 ` Theodore Y. Ts'o
2021-11-26 14:50 ` Vlastimil Babka
2021-11-26 15:09 ` Michal Hocko [this message]
2021-11-24 8:43 ` Michal Hocko
2021-11-24 20:37 ` Uladzislau Rezki
2021-11-25 8:48 ` Michal Hocko
2021-11-25 18:40 ` Uladzislau Rezki
2021-11-25 19:21 ` Michal Hocko
2021-11-24 20:11 ` Uladzislau Rezki
2021-11-25 8:46 ` Michal Hocko
2021-11-25 18:02 ` Uladzislau Rezki
2021-11-25 19:24 ` Michal Hocko
2021-11-25 20:03 ` Uladzislau Rezki
2021-11-25 20:13 ` Michal Hocko
2021-11-25 20:21 ` Uladzislau Rezki
2021-11-26 10:48 ` Michal Hocko
2021-11-28 0:00 ` Andrew Morton
2021-11-29 8:56 ` Michal Hocko
2021-11-26 15:32 ` Vlastimil Babka
2021-11-22 15:32 ` [PATCH v2 3/4] mm/vmalloc: be more explicit about supported gfp flags Michal Hocko
2021-11-23 18:58 ` Uladzislau Rezki
2021-11-26 15:39 ` Vlastimil Babka
2021-11-22 15:32 ` [PATCH v2 4/4] mm: allow !GFP_KERNEL allocations for kvmalloc Michal Hocko
2021-11-23 18:57 ` Uladzislau Rezki
2021-11-23 19:02 ` Uladzislau Rezki
2021-11-26 15:50 ` Vlastimil Babka
2021-11-24 22:55 ` [PATCH v2 0/4] extend vmalloc support for constrained allocations Dave Chinner
2021-11-25 8:58 ` Michal Hocko
2021-11-25 9:30 ` Michal Hocko
2021-11-25 21:30 ` Dave Chinner
2021-11-26 9:20 ` Vlastimil Babka
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=YaD4tFV1P4vwBVEL@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=hch@lst.de \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=neilb@suse.de \
--cc=urezki@gmail.com \
--cc=vbabka@suse.cz \
/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