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

vfs: move inode stat information closer together

The comment above it says "Stat data, not accessed from path walking",
but in fact some of inode fields we use for the common stat data was way
down at the end of the inode, causing unnecessary cache misses for the
common stat operations.

The inode structure is pretty big, and this can change padding depending
on field width, but at least on the common 64-bit configurations this
doesn't change the size. Some of our inode layout has historically been
to tro to avoid unnecessary padding fields, but cache locality is at
least as important for layout, if not more.

Noticed by looking at kernel profiles, and noticing that the "i_blkbits"
access stood out like a sore thumb.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+3 -3
+3 -3
include/linux/fs.h
··· 802 802 unsigned int __i_nlink; 803 803 }; 804 804 dev_t i_rdev; 805 + loff_t i_size; 805 806 struct timespec i_atime; 806 807 struct timespec i_mtime; 807 808 struct timespec i_ctime; 808 809 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 809 810 unsigned short i_bytes; 811 + unsigned int i_blkbits; 810 812 blkcnt_t i_blocks; 811 - loff_t i_size; 812 813 813 814 #ifdef __NEED_I_SIZE_ORDERED 814 815 seqcount_t i_size_seqcount; ··· 829 828 struct list_head i_dentry; 830 829 struct rcu_head i_rcu; 831 830 }; 832 - atomic_t i_count; 833 - unsigned int i_blkbits; 834 831 u64 i_version; 832 + atomic_t i_count; 835 833 atomic_t i_dio_count; 836 834 atomic_t i_writecount; 837 835 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */