Skip to content

Commit b6b3fde

Browse files
Eric DumazetAl Viro
authored andcommitted
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>
1 parent fd659fd commit b6b3fde

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎fs/dcache.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,9 +2314,6 @@ static void __init dcache_init(void)
23142314
/* SLAB cache for __getname() consumers */
23152315
struct kmem_cache *names_cachep __read_mostly;
23162316

2317-
/* SLAB cache for file structures */
2318-
struct kmem_cache *filp_cachep __read_mostly;
2319-
23202317
EXPORT_SYMBOL(d_genocide);
23212318

23222319
void __init vfs_caches_init_early(void)
@@ -2338,9 +2335,6 @@ void __init vfs_caches_init(unsigned long mempages)
23382335
names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
23392336
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
23402337

2341-
filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
2342-
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
2343-
23442338
dcache_init();
23452339
inode_init();
23462340
files_init(mempages);

‎fs/file_table.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ struct files_stat_struct files_stat = {
3232
/* public. Not pretty! */
3333
__cacheline_aligned_in_smp DEFINE_SPINLOCK(files_lock);
3434

35+
/* SLAB cache for file structures */
36+
static struct kmem_cache *filp_cachep __read_mostly;
37+
3538
static struct percpu_counter nr_files __cacheline_aligned_in_smp;
3639

3740
static inline void file_free_rcu(struct rcu_head *head)
@@ -397,7 +400,12 @@ int fs_may_remount_ro(struct super_block *sb)
397400
void __init files_init(unsigned long mempages)
398401
{
399402
int n;
400-
/* One file with associated inode and dcache is very roughly 1K.
403+
404+
filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
405+
SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
406+
407+
/*
408+
* One file with associated inode and dcache is very roughly 1K.
401409
* Per default don't use more than 10% of our memory for files.
402410
*/
403411

‎include/linux/fdtable.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ struct files_struct {
5757

5858
#define files_fdtable(files) (rcu_dereference((files)->fdt))
5959

60-
extern struct kmem_cache *filp_cachep;
61-
6260
struct file_operations;
6361
struct vfsmount;
6462
struct dentry;

0 commit comments

Comments
 (0)