From: Andrew Morton <akpm@linux-foundation.org>
To: David Rientjes <rientjes@google.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
Christoph Hellwig <hch@infradead.org>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org
Subject: Re: [patch] fs, seq_file: fallback to vmalloc instead of oom kill processes
Date: Wed, 26 Nov 2014 14:48:46 -0800 [thread overview]
Message-ID: <20141126144846.d7a3ec1a2a0c20d9cb1a7c49@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1411261434080.13014@chino.kir.corp.google.com>
On Wed, 26 Nov 2014 14:40:06 -0800 (PST) David Rientjes <rientjes@google.com> wrote:
> On Wed, 26 Nov 2014, Andrew Morton wrote:
>
> > You forgot something.
> >
> > --- a/fs/seq_file.c~fs-seq_file-fallback-to-vmalloc-instead-of-oom-kill-processes-fix
> > +++ a/fs/seq_file.c
> > @@ -36,6 +36,10 @@ static void *seq_buf_alloc(unsigned long
> > {
> > void *buf;
> >
> > + /*
> > + * __GFP_NORETRY to avoid oom-killings with high-order allocations -
> > + * it's better to fall back to vmalloc() than to kill things.
> > + */
> > buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
> > if (!buf && size > PAGE_SIZE)
> > buf = vmalloc(size);
> >
>
> ...
>
> The slowpath tries to allocate, calls memory compaction if necessary,
> tries to allocate, calls direct reclaim, tries to allocate, call the oom
> killer and tries to allocate if we are going to loop, and then loop if
> allowed. There's no need to try to allocate if we don't call the oom
> killer since it won't succeed and there's no need to call the oom killer
> to free memory if we aren't going to retry.
My concern is that an open-coded __GFP_NORETRY is very obscure. Even
something like
#define __GFP_NO_OOM_KILL __GFP_NORETRY
would help make things a bit self-documenting.
> Even if __GFP_NO_OOM_KILL existed, it wouldn't be applicable to this
> patch: the change here is that seqfile will now return -ENOMEM instead of
> oom killing processes;
Not really? The change makes seq_buf_alloc() fall back to vmalloc()
rather than killing things. Doesn't it?
Unless the allocation is < PAGE_SIZE, in which case we do go ENOMEM.
That's daft - it would be better to vmalloc() a whole page in this
case. Not that the vmalloc is likely to be successful anyway..
> the slab allocation will no longer loop forever
> trying to allocate memory.
prev parent reply other threads:[~2014-11-26 22:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 22:16 David Rientjes
2014-11-26 22:24 ` Andrew Morton
2014-11-26 22:38 ` Joe Perches
2014-11-26 22:40 ` David Rientjes
2014-11-26 22:48 ` Andrew Morton [this message]
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=20141126144846.d7a3ec1a2a0c20d9cb1a7c49@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®