* [PATCH] fs, seqfile: always allow oom killer
@ 2015-09-25 7:43 Greg Thelen
2015-09-25 13:13 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Greg Thelen @ 2015-09-25 7:43 UTC (permalink / raw)
To: Alexander Viro, Andrew Morton
Cc: David Rientjes, linux-fsdevel, linux-kernel, Greg Thelen
Since commit 5cec38ac866b ("fs, seq_file: fallback to vmalloc instead of
oom kill processes") seq_buf_alloc() avoids calling the oom killer for
PAGE_SIZE or smaller allocations; but larger allocations can use the oom
killer via vmalloc(). Thus reads of small files can return ENOMEM, but
larger files use the oom killer to avoid ENOMEM.
Memory overcommit requires use of the oom killer to select a victim
regardless of file size.
Enable oom killer for small seq_buf_alloc() allocations.
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Greg Thelen <gthelen@google.com>
---
fs/seq_file.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 225586e141ca..a8e288755f24 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -25,12 +25,17 @@ static void seq_set_overflow(struct seq_file *m)
static void *seq_buf_alloc(unsigned long size)
{
void *buf;
+ gfp_t gfp = GFP_KERNEL;
/*
- * __GFP_NORETRY to avoid oom-killings with high-order allocations -
- * it's better to fall back to vmalloc() than to kill things.
+ * For high order allocations, use __GFP_NORETRY to avoid oom-killing -
+ * it's better to fall back to vmalloc() than to kill things. For small
+ * allocations, just use GFP_KERNEL which will oom kill, thus no need
+ * for vmalloc fallback.
*/
- buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
+ if (size > PAGE_SIZE)
+ gfp |= __GFP_NORETRY | __GFP_NOWARN;
+ buf = kmalloc(size, gfp);
if (!buf && size > PAGE_SIZE)
buf = vmalloc(size);
return buf;
--
2.6.0.rc2.230.g3dd15c0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] fs, seqfile: always allow oom killer
2015-09-25 7:43 [PATCH] fs, seqfile: always allow oom killer Greg Thelen
@ 2015-09-25 13:13 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2015-09-25 13:13 UTC (permalink / raw)
To: Greg Thelen
Cc: Alexander Viro, Andrew Morton, David Rientjes, linux-fsdevel,
linux-kernel
On Fri, 2015-09-25 at 00:43 -0700, Greg Thelen wrote:
> Since commit 5cec38ac866b ("fs, seq_file: fallback to vmalloc instead of
> oom kill processes") seq_buf_alloc() avoids calling the oom killer for
> PAGE_SIZE or smaller allocations; but larger allocations can use the oom
> killer via vmalloc(). Thus reads of small files can return ENOMEM, but
> larger files use the oom killer to avoid ENOMEM.
>
> Memory overcommit requires use of the oom killer to select a victim
> regardless of file size.
>
> Enable oom killer for small seq_buf_alloc() allocations.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
> Signed-off-by: Greg Thelen <gthelen@google.com>
> ---
Acked-by: Eric Dumazet <edumazet@google.com>
Thanks guys.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-25 13:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-25 7:43 [PATCH] fs, seqfile: always allow oom killer Greg Thelen
2015-09-25 13:13 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome