aboutsummaryrefslogtreecommitdiffstats
path: root/fs/file.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2011-04-27 18:26:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-04-28 14:28:20 -0400
commit6d4831c283530a5f2c6bd8172c13efa236eb149d (patch)
tree4d199a330cfe8710de0deb4e805a798c2982501c /fs/file.c
parente8dad69408a9812d6bb42d03e74d2c314534a4fa (diff)
vfs: avoid large kmalloc()s for the fdtable
Azurit reports large increases in system time after 2.6.36 when running Apache. It was bisected down to a892e2d7dcdfa6c76e6 ("vfs: use kmalloc() to allocate fdmem if possible"). That patch caused the vfs to use kmalloc() for very large allocations and this is causing excessive work (and presumably excessive reclaim) within the page allocator. Fix it by falling back to vmalloc() earlier - when the allocation attempt would have been considered "costly" by reclaim. Reported-by: azurIt <azurit@pobox.sk> Tested-by: azurIt <azurit@pobox.sk> Acked-by: Changli Gao <xiaosuo@gmail.com> Cc: Americo Wang <xiyou.wangcong@gmail.com> Cc: Jiri Slaby <jslaby@suse.cz> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/file.c')
-rw-r--r--fs/file.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/file.c b/fs/file.c
index 0be344755c02..4c6992d8f3ba 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -9,6 +9,7 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/mmzone.h>
12#include <linux/time.h> 13#include <linux/time.h>
13#include <linux/sched.h> 14#include <linux/sched.h>
14#include <linux/slab.h> 15#include <linux/slab.h>
@@ -39,14 +40,17 @@ int sysctl_nr_open_max = 1024 * 1024; /* raised later */
39 */ 40 */
40static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list); 41static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list);
41 42
42static inline void *alloc_fdmem(unsigned int size) 43static void *alloc_fdmem(unsigned int size)
43{ 44{
44 void *data; 45 /*
45 46 * Very large allocations can stress page reclaim, so fall back to
46 data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN); 47 * vmalloc() if the allocation size will be considered "large" by the VM.
47 if (data != NULL) 48 */
48 return data; 49 if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
49 50 void *data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
51 if (data != NULL)
52 return data;
53 }
50 return vmalloc(size); 54 return vmalloc(size);
51} 55}
52 56