* [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask`
@ 2026-11-11 15:36 Max Kellermann
2026-11-12 18:36 ` Jan Kara
0 siblings, 1 reply; 4+ messages in thread
From: Max Kellermann @ 2026-11-11 15:36 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: Max Kellermann, linux-fsdevel, linux-kernel
Both were 32 bit fields followed by a 32 bit hole. This reduces size
of `struct inode` by 8 bytes.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
include/linux/fs.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5b3a100aba77..9ab028dabc1b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask`
2026-11-11 15:36 [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask` Max Kellermann
@ 2026-11-12 18:36 ` Jan Kara
2026-11-13 8:07 ` Max Kellermann
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2026-11-12 18:36 UTC (permalink / raw)
To: Max Kellermann
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel,
linux-kernel
On Wed 11-11-26 16:36:30, Max Kellermann wrote:
> Both were 32 bit fields followed by a 32 bit hole. This reduces size
> of `struct inode` by 8 bytes.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
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
> ---
> include/linux/fs.h | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5b3a100aba77..9ab028dabc1b 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask`
2026-11-12 18:36 ` Jan Kara
@ 2026-11-13 8:07 ` Max Kellermann
2026-11-13 10:49 ` Jan Kara
0 siblings, 1 reply; 4+ messages in thread
From: Max Kellermann @ 2026-11-13 8:07 UTC (permalink / raw)
To: Jan Kara; +Cc: Alexander Viro, Christian Brauner, linux-fsdevel, linux-kernel
On Thu, Nov 12, 2026 at 7:38 PM Jan Kara <jack@suse.cz> 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.
--
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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask`
2026-11-13 8:07 ` Max Kellermann
@ 2026-11-13 10:49 ` Jan Kara
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2026-11-13 10:49 UTC (permalink / raw)
To: Max Kellermann
Cc: Jan Kara, Alexander Viro, Christian Brauner, linux-fsdevel,
linux-kernel
On Fri 13-11-26 09:07:44, Max Kellermann wrote:
> On Thu, Nov 12, 2026 at 7:38 PM Jan Kara <jack@suse.cz> 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@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-13 10:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 15:36 [PATCH] fs: pack fields `i_state` and `i_fsnotify_mask` Max Kellermann
2026-11-12 18:36 ` Jan Kara
2026-11-13 8:07 ` Max Kellermann
2026-11-13 10:49 ` Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.