Commit 99c228a9 authored by Amir Goldstein's avatar Amir Goldstein Committed by Jan Kara

fs: group frequently accessed fields of struct super_block together

Kernel test robot reported [1] a 6% performance regression in a
concurrent unlink(2) workload on commit 60f7ed8c ("fsnotify: send
path type events to group with super block marks").

The performance test was run with no fsnotify marks at all on the
data set, so the only extra instructions added by the offending
commit are tests of the super_block fields s_fsnotify_{marks,mask}
and these tests happen on almost every single inode access.

When adding those fields to the super_block struct, we did not give much
thought of placing them on a hot cache lines (we just placed them at the
end of the struct).

Re-organize struct super_block to try and keep some frequently accessed
fields on the same cache line.

Move the frequently accessed fields s_fsnotify_{marks,mask} near the
frequently accessed fields s_fs_info,s_time_gran, while filling a 64bit
alignment hole after s_time_gran.

Move the seldom accessed fields s_id,s_uuid,s_max_links,s_mode near the
seldom accessed fields s_vfs_rename_mutex,s_subtype.

Rong Chen confirmed that this patch solved the reported problem.

[1] https://lkml.org/lkml/2018/9/30/206Reported-by: default avatarkernel test robot <rong.a.chen@intel.com>
Tested-by: default avatarkernel test robot <rong.a.chen@intel.com>
Fixes: 1e6cb723 ("fsnotify: add super block object type")
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent d0a6a87e
...@@ -1393,17 +1393,26 @@ struct super_block { ...@@ -1393,17 +1393,26 @@ struct super_block {
struct sb_writers s_writers; struct sb_writers s_writers;
/*
* Keep s_fs_info, s_time_gran, s_fsnotify_mask, and
* s_fsnotify_marks together for cache efficiency. They are frequently
* accessed and rarely modified.
*/
void *s_fs_info; /* Filesystem private info */
/* Granularity of c/m/atime in ns (cannot be worse than a second) */
u32 s_time_gran;
#ifdef CONFIG_FSNOTIFY
__u32 s_fsnotify_mask;
struct fsnotify_mark_connector __rcu *s_fsnotify_marks;
#endif
char s_id[32]; /* Informational name */ char s_id[32]; /* Informational name */
uuid_t s_uuid; /* UUID */ uuid_t s_uuid; /* UUID */
void *s_fs_info; /* Filesystem private info */
unsigned int s_max_links; unsigned int s_max_links;
fmode_t s_mode; fmode_t s_mode;
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
/* /*
* The next field is for VFS *only*. No filesystems have any business * The next field is for VFS *only*. No filesystems have any business
* even looking at it. You had been warned. * even looking at it. You had been warned.
...@@ -1464,11 +1473,6 @@ struct super_block { ...@@ -1464,11 +1473,6 @@ struct super_block {
spinlock_t s_inode_wblist_lock; spinlock_t s_inode_wblist_lock;
struct list_head s_inodes_wb; /* writeback inodes */ struct list_head s_inodes_wb; /* writeback inodes */
#ifdef CONFIG_FSNOTIFY
__u32 s_fsnotify_mask;
struct fsnotify_mark_connector __rcu *s_fsnotify_marks;
#endif
} __randomize_layout; } __randomize_layout;
/* Helper functions so that in most cases filesystems will /* Helper functions so that in most cases filesystems will
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment