aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2005-10-30 18:02:16 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:19 -0500
commit2f51201662b28dbf8c15fb7eb972bc51c6cc3fa5 (patch)
tree96826df796058560bc5dd1f7d8d476c5a741d7bc /fs
parent503af334ecf23b9d65d2ff0cc759f3a0bf338290 (diff)
[PATCH] reduce sizeof(struct file)
Now that RCU applied on 'struct file' seems stable, we can place f_rcuhead in a memory location that is not anymore used at call_rcu(&f->f_rcuhead, file_free_rcu) time, to reduce the size of this critical kernel object. The trick I used is to move f_rcuhead and f_list in an union called f_u The callers are changed so that f_rcuhead becomes f_u.fu_rcuhead and f_list becomes f_u.f_list Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/dquot.c2
-rw-r--r--fs/file_table.c14
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/super.c2
4 files changed, 10 insertions, 10 deletions
diff --git a/fs/dquot.c b/fs/dquot.c
index 05f3327d64a3..ea7644227a65 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -662,7 +662,7 @@ static void add_dquot_ref(struct super_block *sb, int type)
662restart: 662restart:
663 file_list_lock(); 663 file_list_lock();
664 list_for_each(p, &sb->s_files) { 664 list_for_each(p, &sb->s_files) {
665 struct file *filp = list_entry(p, struct file, f_list); 665 struct file *filp = list_entry(p, struct file, f_u.fu_list);
666 struct inode *inode = filp->f_dentry->d_inode; 666 struct inode *inode = filp->f_dentry->d_inode;
667 if (filp->f_mode & FMODE_WRITE && dqinit_needed(inode, type)) { 667 if (filp->f_mode & FMODE_WRITE && dqinit_needed(inode, type)) {
668 struct dentry *dentry = dget(filp->f_dentry); 668 struct dentry *dentry = dget(filp->f_dentry);
diff --git a/fs/file_table.c b/fs/file_table.c
index 86ec8ae985b4..4dc205546547 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -56,13 +56,13 @@ void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags)
56 56
57static inline void file_free_rcu(struct rcu_head *head) 57static inline void file_free_rcu(struct rcu_head *head)
58{ 58{
59 struct file *f = container_of(head, struct file, f_rcuhead); 59 struct file *f = container_of(head, struct file, f_u.fu_rcuhead);
60 kmem_cache_free(filp_cachep, f); 60 kmem_cache_free(filp_cachep, f);
61} 61}
62 62
63static inline void file_free(struct file *f) 63static inline void file_free(struct file *f)
64{ 64{
65 call_rcu(&f->f_rcuhead, file_free_rcu); 65 call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);
66} 66}
67 67
68/* Find an unused file structure and return a pointer to it. 68/* Find an unused file structure and return a pointer to it.
@@ -95,7 +95,7 @@ struct file *get_empty_filp(void)
95 f->f_gid = current->fsgid; 95 f->f_gid = current->fsgid;
96 rwlock_init(&f->f_owner.lock); 96 rwlock_init(&f->f_owner.lock);
97 /* f->f_version: 0 */ 97 /* f->f_version: 0 */
98 INIT_LIST_HEAD(&f->f_list); 98 INIT_LIST_HEAD(&f->f_u.fu_list);
99 return f; 99 return f;
100 100
101over: 101over:
@@ -225,15 +225,15 @@ void file_move(struct file *file, struct list_head *list)
225 if (!list) 225 if (!list)
226 return; 226 return;
227 file_list_lock(); 227 file_list_lock();
228 list_move(&file->f_list, list); 228 list_move(&file->f_u.fu_list, list);
229 file_list_unlock(); 229 file_list_unlock();
230} 230}
231 231
232void file_kill(struct file *file) 232void file_kill(struct file *file)
233{ 233{
234 if (!list_empty(&file->f_list)) { 234 if (!list_empty(&file->f_u.fu_list)) {
235 file_list_lock(); 235 file_list_lock();
236 list_del_init(&file->f_list); 236 list_del_init(&file->f_u.fu_list);
237 file_list_unlock(); 237 file_list_unlock();
238 } 238 }
239} 239}
@@ -245,7 +245,7 @@ int fs_may_remount_ro(struct super_block *sb)
245 /* Check that no files are currently opened for writing. */ 245 /* Check that no files are currently opened for writing. */
246 file_list_lock(); 246 file_list_lock();
247 list_for_each(p, &sb->s_files) { 247 list_for_each(p, &sb->s_files) {
248 struct file *file = list_entry(p, struct file, f_list); 248 struct file *file = list_entry(p, struct file, f_u.fu_list);
249 struct inode *inode = file->f_dentry->d_inode; 249 struct inode *inode = file->f_dentry->d_inode;
250 250
251 /* File with pending delete? */ 251 /* File with pending delete? */
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 8a8c34461d48..b638fb500743 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -533,7 +533,7 @@ static void proc_kill_inodes(struct proc_dir_entry *de)
533 */ 533 */
534 file_list_lock(); 534 file_list_lock();
535 list_for_each(p, &sb->s_files) { 535 list_for_each(p, &sb->s_files) {
536 struct file * filp = list_entry(p, struct file, f_list); 536 struct file * filp = list_entry(p, struct file, f_u.fu_list);
537 struct dentry * dentry = filp->f_dentry; 537 struct dentry * dentry = filp->f_dentry;
538 struct inode * inode; 538 struct inode * inode;
539 struct file_operations *fops; 539 struct file_operations *fops;
diff --git a/fs/super.c b/fs/super.c
index 6e57ee252e14..f60155ec7780 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -513,7 +513,7 @@ static void mark_files_ro(struct super_block *sb)
513 struct file *f; 513 struct file *f;
514 514
515 file_list_lock(); 515 file_list_lock();
516 list_for_each_entry(f, &sb->s_files, f_list) { 516 list_for_each_entry(f, &sb->s_files, f_u.fu_list) {
517 if (S_ISREG(f->f_dentry->d_inode->i_mode) && file_count(f)) 517 if (S_ISREG(f->f_dentry->d_inode->i_mode) && file_count(f))
518 f->f_mode &= ~FMODE_WRITE; 518 f->f_mode &= ~FMODE_WRITE;
519 } 519 }