Commit d8fbaf73 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] Automatic file-max sizing

The default for NR_FILES of 8192 is far too low for many workloads. This
patch does dynamic sizing for it instead. It assumes file+inode+dentry
are roughly 1K and will use upto 10% of the memory for it.

Also removes two obsolete prototypes.
parent 0c16b441
...@@ -1283,6 +1283,7 @@ void __init vfs_caches_init(unsigned long mempages) ...@@ -1283,6 +1283,7 @@ void __init vfs_caches_init(unsigned long mempages)
dcache_init(mempages); dcache_init(mempages);
inode_init(mempages); inode_init(mempages);
files_init(mempages);
mnt_init(mempages); mnt_init(mempages);
bdev_cache_init(); bdev_cache_init();
cdev_cache_init(); cdev_cache_init();
......
...@@ -186,3 +186,17 @@ int fs_may_remount_ro(struct super_block *sb) ...@@ -186,3 +186,17 @@ int fs_may_remount_ro(struct super_block *sb)
file_list_unlock(); file_list_unlock();
return 0; return 0;
} }
void __init files_init(unsigned long mempages)
{
int n;
/* One file with associated inode and dcache is very roughly 1K.
* Per default don't use more than 10% of our memory for files.
*/
n = (mempages * (PAGE_SIZE / 1024)) / 10;
files_stat.max_files = n;
if (files_stat.max_files < NR_FILE)
files_stat.max_files = NR_FILE;
}
...@@ -208,6 +208,7 @@ extern void update_atime (struct inode *); ...@@ -208,6 +208,7 @@ extern void update_atime (struct inode *);
extern void buffer_init(unsigned long); extern void buffer_init(unsigned long);
extern void inode_init(unsigned long); extern void inode_init(unsigned long);
extern void mnt_init(unsigned long); extern void mnt_init(unsigned long);
extern void files_init(unsigned long);
/* bh state bits */ /* bh state bits */
enum bh_state_bits { enum bh_state_bits {
...@@ -1492,8 +1493,6 @@ static inline int is_mounted(kdev_t dev) ...@@ -1492,8 +1493,6 @@ static inline int is_mounted(kdev_t dev)
} }
return 0; return 0;
} }
unsigned long generate_cluster(kdev_t, int b[], int);
unsigned long generate_cluster_swab32(kdev_t, int b[], int);
extern kdev_t ROOT_DEV; extern kdev_t ROOT_DEV;
extern char root_device_name[]; extern char root_device_name[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment