fs: pack fields `i_state` and `i_fsnotify_mask`
PATCH 1/1 fs: pack fields `i_state` and `i_fsnotify_mask`
Both were 32 bit fields followed by a 32 bit hole. This reduces size of struct inode by 8 bytes.
--- include/linux/fs.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
include/linux/fs.h +5 -3
@@ -813,7 +813,11 @@ struct inode {/* Misc */ struct inode_state_flags i_state; -/* 32-bit hole */ + +#ifdef CONFIG_FSNOTIFY +__u32 i_fsnotify_mask;/* all events this inode cares about */ +#endif +struct rw_semaphore i_rwsem;/* Timestamp for writeback list ordering and age checks (jiffies). */
@@ -865,8 +869,6 @@ struct inode {#ifdef CONFIG_FSNOTIFY -__u32 i_fsnotify_mask;/* all events this inode cares about */ -/* 32-bit hole reserved for expanding i_fsnotify_mask */ struct fsnotify_mark_connector __rcu *i_fsnotify_marks;#endif
Signature · 1 line
2.53.0
Jan Kara
reviewerQuoted 4 lines · Max Kellermann
Both were 32 bit fields followed by a 32 bit hole. This reduces size of
struct inodeby 8 bytes.Signed-off-by Max Kellermann <[email protected]>
When moving i_fsnotify_mask please move it along with i_fsnotify_marks. It should better be in the same cacheline because these two are accessed on some performance sensitive paths.
Honza
Quoted 33 lines
--- include/linux/fs.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)include/linux/fs.h +5
-3@@ -813,7 +813,11 @@ struct inode {/* Misc */ struct inode_state_flags i_state; -/* 32-bit hole */ + +#ifdef CONFIG_FSNOTIFY +__u32 i_fsnotify_mask;/* all events this inode cares about */ +#endif +struct rw_semaphore i_rwsem;/* Timestamp for writeback list ordering and age checks (jiffies). */ @@ -865,8 +869,6 @@ struct inode {#ifdef CONFIG_FSNOTIFY -__u32 i_fsnotify_mask;/* all events this inode cares about */ -/* 32-bit hole reserved for expanding i_fsnotify_mask */ struct fsnotify_mark_connector __rcu *i_fsnotify_marks;#endif Signature · 1 line
2.53.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 3 lines · Jan Kara
When moving
i_fsnotify_maskplease move it along withi_fsnotify_marks. It should better be in the same cacheline because these two are accessed on some performance sensitive paths.
Tried that, but:
struct inode_state_flags i_state; /* 120 4 */
__u32 i_fsnotify_mask; /* 124 4 */ /* --- cacheline 2 boundary (128 bytes) --- */
struct fsnotify_mark_connector * i_fsnotify_marks; /* 128 8 */
The cacheline happened to end after "i_state" (and now "i_fsnotify_mask"). I could move "i_state" down instead, or move other fields around - but you're a better expert here, please advise what you believe is best.
Signature · 8 lines
Max Kellermann Principal Architect Hosting Technology cm4all | Im Mediapark 6a | 50670 Köln | Germany General information about the company can be found here: https://www.cm4all.com/impressum A member of the IONOS Group
Jan Kara
reviewerQuoted 9 lines · Max Kellermann
Quoted 3 lines · Jan Kara
When moving
i_fsnotify_maskplease move it along withi_fsnotify_marks. It should better be in the same cacheline because these two are accessed on some performance sensitive paths.Tried that, but:
struct inode_state_flags i_state; /* 120 4 */ __u32 i_fsnotify_mask; /* 124 4 */
Quoted 7 lines
/* --- cacheline 2 boundary (128 bytes) --- */
structfsnotify_mark_connector*i_fsnotify_marks; /* 128 8 */The cacheline happened to end after "
i_state" (and now "i_fsnotify_mask"). I could move "i_state" down instead, or move other fields around - but you're a better expert here, please advise what you believe is best.
I have checked and none of the big filesystems (xfs, btrfs, ext4, tmpfs) place struct inode to the beginning of their inode allocations. So where exactly the cacheline boundary ends up being is kind of random anyway (plus the allocations of the inode structures aren't cacheline aligned anyway). So I'd just keep these two fields together to have a good chance of them not being in different cachelines and leave the rest on $deity. ;)
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR