diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-08-17 11:41:59 +0300 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-08-17 11:41:59 +0300 |
commit | 5461bd81bf7f86503f393b0b1d57e69b1f1bd44e (patch) | |
tree | 25ec4a2f43019c4d7cc76eb6a967ec450add9401 /fs/file_table.c | |
parent | 949163015ce6fdb76a5e846a3582d3c40c23c001 (diff) | |
parent | 2c6625cd545bdd66acff14f3394865d43920a5c7 (diff) | |
download | linux-5461bd81bf7f86503f393b0b1d57e69b1f1bd44e.tar.xz |
Merge tag 'v4.2-rc7' into x86/boot, to refresh the branch before merging new changes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/file_table.c')
-rw-r--r-- | fs/file_table.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/file_table.c b/fs/file_table.c index 7f9d407c7595..ad17e05ebf95 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -25,6 +25,7 @@ #include <linux/hardirq.h> #include <linux/task_work.h> #include <linux/ima.h> +#include <linux/swap.h> #include <linux/atomic.h> @@ -308,19 +309,24 @@ void put_filp(struct file *file) } } -void __init files_init(unsigned long mempages) +void __init files_init(void) { - unsigned long n; - filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); + percpu_counter_init(&nr_files, 0, GFP_KERNEL); +} - /* - * One file with associated inode and dcache is very roughly 1K. - * Per default don't use more than 10% of our memory for files. - */ +/* + * One file with associated inode and dcache is very roughly 1K. Per default + * do not use more than 10% of our memory for files. + */ +void __init files_maxfiles_init(void) +{ + unsigned long n; + unsigned long memreserve = (totalram_pages - nr_free_pages()) * 3/2; + + memreserve = min(memreserve, totalram_pages - 1); + n = ((totalram_pages - memreserve) * (PAGE_SIZE / 1024)) / 10; - n = (mempages * (PAGE_SIZE / 1024)) / 10; files_stat.max_files = max_t(unsigned long, n, NR_FILE); - percpu_counter_init(&nr_files, 0, GFP_KERNEL); } |