Re: [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask`
From: Jan Kara
Date: Fri Nov 13 2026 - 08:35:49 EST
On Fri 13-11-26 09:07:44, Max Kellermann wrote:
> On Thu, Nov 12, 2026 at 7:38 PM Jan Kara <jack@xxxxxxx> wrote:
> > 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.
>
> 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.
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
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR