From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: David Rientjes <rientjes@google.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Christoph Hellwig <hch@infradead.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Slaby <jslaby@suse.cz>
Subject: [patch added to 3.12-stable] fs, seq_file: fallback to vmalloc instead of oom kill processes
Date: Thu, 21 Apr 2016 14:14:15 +0200 [thread overview]
Message-ID: <1461240870-2373-2-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1461240870-2373-1-git-send-email-jslaby@suse.cz>
From: David Rientjes <rientjes@google.com>
This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.
===============
commit 5cec38ac866bfb8775638e71a86e4d8cac30caae upstream.
Since commit 058504edd026 ("fs/seq_file: fallback to vmalloc allocation"),
seq_buf_alloc() falls back to vmalloc() when the kmalloc() for contiguous
memory fails. This was done to address order-4 slab allocations for
reading /proc/stat on large machines and noticed because
PAGE_ALLOC_COSTLY_ORDER < 4, so there is no infinite loop in the page
allocator when allocating new slab for such high-order allocations.
Contiguous memory isn't necessary for caller of seq_buf_alloc(), however.
Other GFP_KERNEL high-order allocations that are <=
PAGE_ALLOC_COSTLY_ORDER will simply loop forever in the page allocator and
oom kill processes as a result.
We don't want to kill processes so that we can allocate contiguous memory
in situations when contiguous memory isn't necessary.
This patch does the kmalloc() allocation with __GFP_NORETRY for high-order
allocations. This still utilizes memory compaction and direct reclaim in
the allocation path, the only difference is that it will fail immediately
instead of oom kill processes when out of memory.
[akpm@linux-foundation.org: add comment]
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
fs/seq_file.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 6e050e26af43..96ae14abce98 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -36,7 +36,11 @@ static void *seq_buf_alloc(unsigned long size)
{
void *buf;
- buf = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
+ /*
+ * __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);
return buf;
--
2.8.1
next prev parent reply other threads:[~2016-04-21 12:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 12:14 [patch added to 3.12-stable] cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind Jiri Slaby
2016-04-21 12:14 ` Jiri Slaby [this message]
2016-04-21 12:14 ` [patch added to 3.12-stable] fs, seqfile: always allow oom killer Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] mmc: Allow forward compatibility for eMMC Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] ALSA: timer: Sync timer deletion at closing the system timer Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] SUNRPC: Fix large reads on NFS/RDMA Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] pipe: limit the per-user amount of pages allocated in pipes Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] netfilter: x_tables: validate e->target_offset early Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] netfilter: x_tables: fix unconditional helper Jiri Slaby
2016-04-22 15:38 ` Michal Kubecek
2016-04-23 16:46 ` Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] USB: usbip: fix potential out-of-bounds write Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] fs/pipe.c: skip file_update_time on frozen fs Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] mnt: Move the clear of MNT_LOCKED from copy_tree to it's callers Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] KEYS: Fix handling of stored error in a negatively instantiated user key Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] crypto: crypto_memneq - add equality testing of memory regions w/o timing leaks Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] EVM: Use crypto_memneq() for digest comparisons Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] KVM: x86: removing unused variable Jiri Slaby
2016-04-21 12:14 ` [patch added to 3.12-stable] KVM: x86: Reload pit counters for all channels when restoring state Jiri Slaby
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=1461240870-2373-2-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=heiko.carstens@de.ibm.com \
--cc=rientjes@google.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--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;
as well as URLs for NNTP newsgroup(s).