Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

filp_cachep can be static in fs/file_table.c

Instead of creating the "filp" kmem_cache in vfs_caches_init(),
we can do it a litle be later in files_init(), so that filp_cachep
is static to fs/file_table.c

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Eric Dumazet and committed by
Al Viro
b6b3fdea fd659fd6

+9 -9
-6
fs/dcache.c
··· 2314 2314 /* SLAB cache for __getname() consumers */ 2315 2315 struct kmem_cache *names_cachep __read_mostly; 2316 2316 2317 - /* SLAB cache for file structures */ 2318 - struct kmem_cache *filp_cachep __read_mostly; 2319 - 2320 2317 EXPORT_SYMBOL(d_genocide); 2321 2318 2322 2319 void __init vfs_caches_init_early(void) ··· 2333 2336 mempages -= reserve; 2334 2337 2335 2338 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0, 2336 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2337 - 2338 - filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, 2339 2339 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2340 2340 2341 2341 dcache_init();
+9 -1
fs/file_table.c
··· 32 32 /* public. Not pretty! */ 33 33 __cacheline_aligned_in_smp DEFINE_SPINLOCK(files_lock); 34 34 35 + /* SLAB cache for file structures */ 36 + static struct kmem_cache *filp_cachep __read_mostly; 37 + 35 38 static struct percpu_counter nr_files __cacheline_aligned_in_smp; 36 39 37 40 static inline void file_free_rcu(struct rcu_head *head) ··· 400 397 void __init files_init(unsigned long mempages) 401 398 { 402 399 int n; 403 - /* One file with associated inode and dcache is very roughly 1K. 400 + 401 + filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, 402 + SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); 403 + 404 + /* 405 + * One file with associated inode and dcache is very roughly 1K. 404 406 * Per default don't use more than 10% of our memory for files. 405 407 */ 406 408
-2
include/linux/fdtable.h
··· 57 57 58 58 #define files_fdtable(files) (rcu_dereference((files)->fdt)) 59 59 60 - extern struct kmem_cache *filp_cachep; 61 - 62 60 struct file_operations; 63 61 struct vfsmount; 64 62 struct dentry;