linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "NeilBrown" <neilb@suse.de>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: "Uladzislau Rezki" <urezki@gmail.com>,
	"Michal Hocko" <mhocko@kernel.org>,
	"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>,
	"Michal Hocko" <mhocko@suse.com>
Subject: Re: [PATCH v2 2/4] mm/vmalloc: add support for __GFP_NOFAIL
Date: Wed, 24 Nov 2021 14:16:56 +1100	[thread overview]
Message-ID: <163772381628.1891.9102201563412921921@noble.neil.brown.name> (raw)
In-Reply-To: <20211123170238.f0f780ddb800f1316397f97c@linux-foundation.org>

On Wed, 24 Nov 2021, Andrew Morton wrote:
> 
> I added GFP_NOFAIL back in the mesozoic era because quite a lot of
> sites were doing open-coded try-forever loops.  I thought "hey, they
> shouldn't be doing that in the first place, but let's at least
> centralize the concept to reduce code size, code duplication and so
> it's something we can now grep for".  But longer term, all GFP_NOFAIL
> sites should be reworked to no longer need to do the retry-forever
> thing.  In retrospect, this bright idea of mine seems to have added
> license for more sites to use retry-forever.  Sigh.

One of the costs of not having GFP_NOFAIL (or similar) is lots of
untested failure-path code.

When does an allocation that is allowed to retry and reclaim ever fail
anyway? I think the answer is "only when it has been killed by the oom
killer".  That of course cannot happen to kernel threads, so maybe
kernel threads should never need GFP_NOFAIL??

I'm not sure the above is 100%, but I do think that is the sort of
semantic that we want.  We want to know what kmalloc failure *means*.
We also need well defined and documented strategies to handle it.
mempools are one such strategy, but not always suitable.
preallocating can also be useful but can be clumsy to implement.  Maybe
we should support a process preallocating a bunch of pages which can
only be used by the process - and are auto-freed when the process
returns to user-space.  That might allow the "error paths" to be simple
and early, and subsequent allocations that were GFP_USEPREALLOC would be
safe.

i.e. we need a plan for how to rework all those no-fail call-sites.

NeilBrown

  reply	other threads:[~2021-11-24  3:17 UTC|newest]

Thread overview: 44+ 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 [this message]
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
2021-11-24 23:45         ` Dave Chinner
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=163772381628.1891.9102201563412921921@noble.neil.brown.name \
    --to=neilb@suse.de \
    --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=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=urezki@gmail.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;
as well as URLs for NNTP newsgroup(s).