mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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 a892e2d7dc ("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 <[email protected]>
Tested-by: azurIt <[email protected]>
Acked-by: Changli Gao <[email protected]>
Cc: Americo Wang <[email protected]>
Cc: Jiri Slaby <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
e8dad69408
commit
6d4831c283
1 changed files with 11 additions and 7 deletions
18
fs/file.c
18
fs/file.c
|
|
@ -9,6 +9,7 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/mmzone.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
@ -39,14 +40,17 @@ int sysctl_nr_open_max = 1024 * 1024; /* raised later */
|
|||
*/
|
||||
static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list);
|
||||
|
||||
static inline void *alloc_fdmem(unsigned int size)
|
||||
static void *alloc_fdmem(unsigned int size)
|
||||
{
|
||||
void *data;
|
||||
|
||||
data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
|
||||
if (data != NULL)
|
||||
return data;
|
||||
|
||||
/*
|
||||
* Very large allocations can stress page reclaim, so fall back to
|
||||
* vmalloc() if the allocation size will be considered "large" by the VM.
|
||||
*/
|
||||
if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
|
||||
void *data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
|
||||
if (data != NULL)
|
||||
return data;
|
||||
}
|
||||
return vmalloc(size);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue