Skip to content

Commit

Permalink
fs: optimize out 16 bytes worth of padding in struct inode
Browse files Browse the repository at this point in the history
Rearrange the fields in struct inode so that on an x86_64 system,
fields that require 8-byte alignment don't end up causing 4-byte holes
in the structure.  It reduces the size of struct inode from 568 bytes
to 552 bytes.

Also move the fields protected by i_lock (i_blocks, i_bytes, and
i_size) into the same cache line as i_lock.

Signed-off-by: "Theodore Ts'o" <[email protected]>
  • Loading branch information
tytso committed Oct 29, 2011
1 parent 80e675f commit 6cdbb0e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,20 +771,20 @@ struct inode {
unsigned long i_ino;
unsigned int i_nlink;
dev_t i_rdev;
loff_t i_size;
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
unsigned int i_blkbits;
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
unsigned short i_bytes;
blkcnt_t i_blocks;
loff_t i_size;

#ifdef __NEED_I_SIZE_ORDERED
seqcount_t i_size_seqcount;
#endif

/* Misc */
unsigned long i_state;
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
struct mutex i_mutex;

unsigned long dirtied_when; /* jiffies of first dirtying */
Expand All @@ -798,9 +798,10 @@ struct inode {
struct rcu_head i_rcu;
};
atomic_t i_count;
unsigned int i_blkbits;
u64 i_version;
unsigned short i_bytes;
atomic_t i_dio_count;
atomic_t i_writecount;
const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
struct file_lock *i_flock;
struct address_space i_data;
Expand All @@ -824,7 +825,6 @@ struct inode {
#ifdef CONFIG_IMA
atomic_t i_readcount; /* struct files open RO */
#endif
atomic_t i_writecount;
void *i_private; /* fs or device private pointer */
};

Expand Down

0 comments on commit 6cdbb0e

Please sign in to comment.