diff options
-rw-r--r-- | fs/seq_file.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 00bbe2bfc634..e85664b7c7d9 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -26,12 +26,17 @@ static void seq_set_overflow(struct seq_file *m) | |||
26 | static void *seq_buf_alloc(unsigned long size) | 26 | static void *seq_buf_alloc(unsigned long size) |
27 | { | 27 | { |
28 | void *buf; | 28 | void *buf; |
29 | gfp_t gfp = GFP_KERNEL; | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * __GFP_NORETRY to avoid oom-killings with high-order allocations - | 32 | * For high order allocations, use __GFP_NORETRY to avoid oom-killing - |
32 | * it's better to fall back to vmalloc() than to kill things. | 33 | * it's better to fall back to vmalloc() than to kill things. For small |
34 | * allocations, just use GFP_KERNEL which will oom kill, thus no need | ||
35 | * for vmalloc fallback. | ||
33 | */ | 36 | */ |
34 | buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); | 37 | if (size > PAGE_SIZE) |
38 | gfp |= __GFP_NORETRY | __GFP_NOWARN; | ||
39 | buf = kmalloc(size, gfp); | ||
35 | if (!buf && size > PAGE_SIZE) | 40 | if (!buf && size > PAGE_SIZE) |
36 | buf = vmalloc(size); | 41 | buf = vmalloc(size); |
37 | return buf; | 42 | return buf; |