]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/seq_file.c
Merge branch 'akpm-current/current'
[karo-tx-linux.git] / fs / seq_file.c
index 00bbe2bfc6345ec61b3daf04fc52e3e60c2f6348..e85664b7c7d963522fd7efc938a3d96a27edc651 100644 (file)
@@ -26,12 +26,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;