aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-08-07 01:45:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-07 01:53:23 -0400
commit3ddcd0569cd68f00f3beae9a7959b72918bb91f4 (patch)
tree3f7c591316560b1c22e2cc0700fbcd29aa3fbd7f /include/linux/fs.h
parent830c0f0edca67403d361fe976a25b17356c11f19 (diff)
vfs: optimize inode cache access patterns
The inode structure layout is largely random, and some of the vfs paths really do care. The path lookup in particular is already quite D$ intensive, and profiles show that accessing the 'inode->i_op->xyz' fields is quite costly. We already optimized the dcache to not unnecessarily load the d_op structure for members that are often NULL using the DCACHE_OP_xyz bits in dentry->d_flags, and this does something very similar for the inode ops that are used during pathname lookup. It also re-orders the fields so that the fields accessed by 'stat' are together at the beginning of the inode structure, and roughly in the order accessed. The effect of this seems to be in the 1-2% range for an empty kernel "make -j" run (which is fairly kernel-intensive, mostly in filename lookup), so it's visible. The numbers are fairly noisy, though, and likely depend a lot on exact microarchitecture. So there's more tuning to be done. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h59
1 files changed, 37 insertions, 22 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 786b3b1113cf..178cdb4f1d4a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -738,22 +738,54 @@ static inline int mapping_writably_mapped(struct address_space *mapping)
738struct posix_acl; 738struct posix_acl;
739#define ACL_NOT_CACHED ((void *)(-1)) 739#define ACL_NOT_CACHED ((void *)(-1))
740 740
741#define IOP_FASTPERM 0x0001
742#define IOP_LOOKUP 0x0002
743#define IOP_NOFOLLOW 0x0004
744
745/*
746 * Keep mostly read-only and often accessed (especially for
747 * the RCU path lookup and 'stat' data) fields at the beginning
748 * of the 'struct inode'
749 */
741struct inode { 750struct inode {
742 /* RCU path lookup touches following: */
743 umode_t i_mode; 751 umode_t i_mode;
752 unsigned short i_opflags;
744 uid_t i_uid; 753 uid_t i_uid;
745 gid_t i_gid; 754 gid_t i_gid;
755 unsigned int i_flags;
756
757#ifdef CONFIG_FS_POSIX_ACL
758 struct posix_acl *i_acl;
759 struct posix_acl *i_default_acl;
760#endif
761
746 const struct inode_operations *i_op; 762 const struct inode_operations *i_op;
747 struct super_block *i_sb; 763 struct super_block *i_sb;
764 struct address_space *i_mapping;
748 765
749 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
750 unsigned int i_flags;
751 unsigned long i_state;
752#ifdef CONFIG_SECURITY 766#ifdef CONFIG_SECURITY
753 void *i_security; 767 void *i_security;
754#endif 768#endif
755 struct mutex i_mutex;
756 769
770 /* Stat data, not accessed from path walking */
771 unsigned long i_ino;
772 unsigned int i_nlink;
773 dev_t i_rdev;
774 loff_t i_size;
775 struct timespec i_atime;
776 struct timespec i_mtime;
777 struct timespec i_ctime;
778 unsigned int i_blkbits;
779 blkcnt_t i_blocks;
780
781#ifdef __NEED_I_SIZE_ORDERED
782 seqcount_t i_size_seqcount;
783#endif
784
785 /* Misc */
786 unsigned long i_state;
787 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
788 struct mutex i_mutex;
757 789
758 unsigned long dirtied_when; /* jiffies of first dirtying */ 790 unsigned long dirtied_when; /* jiffies of first dirtying */
759 791
@@ -765,25 +797,12 @@ struct inode {
765 struct list_head i_dentry; 797 struct list_head i_dentry;
766 struct rcu_head i_rcu; 798 struct rcu_head i_rcu;
767 }; 799 };
768 unsigned long i_ino;
769 atomic_t i_count; 800 atomic_t i_count;
770 unsigned int i_nlink;
771 dev_t i_rdev;
772 unsigned int i_blkbits;
773 u64 i_version; 801 u64 i_version;
774 loff_t i_size;
775#ifdef __NEED_I_SIZE_ORDERED
776 seqcount_t i_size_seqcount;
777#endif
778 struct timespec i_atime;
779 struct timespec i_mtime;
780 struct timespec i_ctime;
781 blkcnt_t i_blocks;
782 unsigned short i_bytes; 802 unsigned short i_bytes;
783 atomic_t i_dio_count; 803 atomic_t i_dio_count;
784 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 804 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
785 struct file_lock *i_flock; 805 struct file_lock *i_flock;
786 struct address_space *i_mapping;
787 struct address_space i_data; 806 struct address_space i_data;
788#ifdef CONFIG_QUOTA 807#ifdef CONFIG_QUOTA
789 struct dquot *i_dquot[MAXQUOTAS]; 808 struct dquot *i_dquot[MAXQUOTAS];
@@ -806,10 +825,6 @@ struct inode {
806 atomic_t i_readcount; /* struct files open RO */ 825 atomic_t i_readcount; /* struct files open RO */
807#endif 826#endif
808 atomic_t i_writecount; 827 atomic_t i_writecount;
809#ifdef CONFIG_FS_POSIX_ACL
810 struct posix_acl *i_acl;
811 struct posix_acl *i_default_acl;
812#endif
813 void *i_private; /* fs or device private pointer */ 828 void *i_private; /* fs or device private pointer */
814}; 829};
815 830