mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
get rid of NR_OPEN and introduce a sysctl_nr_open
NR_OPEN (historically set to 1024*1024) actually forbids processes to open more than 1024*1024 handles. Unfortunatly some production servers hit the not so 'ridiculously high value' of 1024*1024 file descriptors per process. Changing NR_OPEN is not considered safe because of vmalloc space potential exhaust. This patch introduces a new sysctl (/proc/sys/fs/nr_open) wich defaults to 1024*1024, so that admins can decide to change this limit if their workload needs it. [[email protected]: export it for sparc64] Signed-off-by: Eric Dumazet <[email protected]> Cc: Alan Cox <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Ralf Baechle <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
774ed22c21
commit
9cfe015aa4
11 changed files with 41 additions and 10 deletions
|
|
@ -24,6 +24,8 @@ struct fdtable_defer {
|
|||
struct fdtable *next;
|
||||
};
|
||||
|
||||
int sysctl_nr_open __read_mostly = 1024*1024;
|
||||
|
||||
/*
|
||||
* We use this list to defer free fdtables that have vmalloced
|
||||
* sets/arrays. By keeping a per-cpu list, we avoid having to embed
|
||||
|
|
@ -147,8 +149,8 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
|
|||
nr /= (1024 / sizeof(struct file *));
|
||||
nr = roundup_pow_of_two(nr + 1);
|
||||
nr *= (1024 / sizeof(struct file *));
|
||||
if (nr > NR_OPEN)
|
||||
nr = NR_OPEN;
|
||||
if (nr > sysctl_nr_open)
|
||||
nr = sysctl_nr_open;
|
||||
|
||||
fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL);
|
||||
if (!fdt)
|
||||
|
|
@ -233,7 +235,7 @@ int expand_files(struct files_struct *files, int nr)
|
|||
if (nr < fdt->max_fds)
|
||||
return 0;
|
||||
/* Can we expand? */
|
||||
if (nr >= NR_OPEN)
|
||||
if (nr >= sysctl_nr_open)
|
||||
return -EMFILE;
|
||||
|
||||
/* All good, so we try */
|
||||
|
|
|
|||
Loading…
Reference in a new issue