* [PATCH v2] fs: pack fields `i_state` and `i_fsnotify_mask`
@ 2026-11-13 11:44 Max Kellermann
2026-11-13 14:58 ` Jan Kara
2026-11-13 20:33 ` David Laight
0 siblings, 2 replies; 3+ messages in thread
From: Max Kellermann @ 2026-11-13 11:44 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.
Moving `i_fsnotify_marks` there as well so they can be in the same
cacheline.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
v1->v2: move `i_fsnotify_marks` up as well because "should better be
in the same cacheline because these two are accessed on some
performance sensitive paths" (Jan Kara)
---
include/linux/fs.h | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5b3a100aba77..fec047cc3327 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -813,7 +813,13 @@ 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 */
+
+ struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
+#endif
+
struct rw_semaphore i_rwsem;
/* Timestamp for writeback list ordering and age checks (jiffies). */
@@ -863,13 +869,6 @@ struct inode {
unsigned i_dir_seq;
};
-
-#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
-
void *i_private; /* fs or device private pointer */
} __randomize_layout;
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] fs: pack fields `i_state` and `i_fsnotify_mask`
2026-11-13 11:44 [PATCH v2] fs: pack fields `i_state` and `i_fsnotify_mask` Max Kellermann
@ 2026-11-13 14:58 ` Jan Kara
2026-11-13 20:33 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-11-13 14:58 UTC (permalink / raw)
To: Max Kellermann
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel, linux-kernel
On Fri 13-11-26 12:44:26, Max Kellermann wrote:
> Both were 32 bit fields followed by a 32 bit hole. This reduces size
> of `struct inode` by 8 bytes.
>
> Moving `i_fsnotify_marks` there as well so they can be in the same
> cacheline.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v1->v2: move `i_fsnotify_marks` up as well because "should better be
> in the same cacheline because these two are accessed on some
> performance sensitive paths" (Jan Kara)
> ---
> include/linux/fs.h | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5b3a100aba77..fec047cc3327 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -813,7 +813,13 @@ 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 */
> +
> + struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
> +#endif
> +
> struct rw_semaphore i_rwsem;
>
> /* Timestamp for writeback list ordering and age checks (jiffies). */
> @@ -863,13 +869,6 @@ struct inode {
> unsigned i_dir_seq;
> };
>
> -
> -#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
> -
> void *i_private; /* fs or device private pointer */
> } __randomize_layout;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] fs: pack fields `i_state` and `i_fsnotify_mask`
2026-11-13 11:44 [PATCH v2] fs: pack fields `i_state` and `i_fsnotify_mask` Max Kellermann
2026-11-13 14:58 ` Jan Kara
@ 2026-11-13 20:33 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2026-11-13 20:33 UTC (permalink / raw)
To: Max Kellermann
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel, linux-kernel
On Fri, 13 Nov 2026 12:44:26 +0100
Max Kellermann <max.kellermann@ionos.com> wrote:
I'd use a different workd than 'pack', made me think of __packed.
> Both were 32 bit fields followed by a 32 bit hole. This reduces size
> of `struct inode` by 8 bytes.
>
> Moving `i_fsnotify_marks` there as well so they can be in the same
> cacheline.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> v1->v2: move `i_fsnotify_marks` up as well because "should better be
> in the same cacheline because these two are accessed on some
> performance sensitive paths" (Jan Kara)
> ---
> include/linux/fs.h | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5b3a100aba77..fec047cc3327 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -813,7 +813,13 @@ 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 */
> +
> + struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
#else
/* 32-bit hole */
??
David
> +#endif
> +
> struct rw_semaphore i_rwsem;
>
> /* Timestamp for writeback list ordering and age checks (jiffies). */
> @@ -863,13 +869,6 @@ struct inode {
> unsigned i_dir_seq;
> };
>
> -
> -#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
> -
> void *i_private; /* fs or device private pointer */
> } __randomize_layout;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-13 20:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 11:44 [PATCH v2] fs: pack fields `i_state` and `i_fsnotify_mask` Max Kellermann
2026-11-13 14:58 ` Jan Kara
2026-11-13 20:33 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®