diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig index 86699c8cab281cbc2960f7433980d14af06f156d..62e9a967f0ed21831aee91d4bb121c437e3adc23 100644 --- a/fs/ext4/Kconfig +++ b/fs/ext4/Kconfig @@ -117,3 +117,12 @@ config EXT4_KUNIT_TESTS to the KUnit documentation in Documentation/dev-tools/kunit/. If unsure, say N. + +config EXT4_MITIGATION_FALSE_SHARING + bool "mitigation false sharing in ext4 inode" + depends on EXT4_FS + default n + help + Enable this to mitigation cacheline false sharing in ext4 inode info. + + If unsure, say N. diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 5d5ae6f44510a712aa45f622bbd0fb6ee92cbeea..45aac9bcd7946fe596c3d94d9180cf9a68b38569 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1090,7 +1090,9 @@ struct ext4_inode_info { * to occasionally drop it. */ struct rw_semaphore i_mmap_sem; +#ifndef CONFIG_EXT4_MITIGATION_FALSE_SHARING struct inode vfs_inode; +#endif struct jbd2_inode *jinode; spinlock_t i_raw_lock; /* protects updates to the raw inode */ @@ -1103,6 +1105,9 @@ struct ext4_inode_info { /* mballoc */ atomic_t i_prealloc_active; +#ifdef CONFIG_EXT4_MITIGATION_FALSE_SHARING + struct inode vfs_inode; +#endif struct list_head i_prealloc_list; spinlock_t i_prealloc_lock; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 753a7f99918427417f97be02140b6edb69375217..06b6e9250bd77aa3cb58a0e2e271ac4759146648 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1420,7 +1420,11 @@ static void init_once(void *foo) static int __init init_inodecache(void) { ext4_inode_cachep = kmem_cache_create_usercopy("ext4_inode_cache", +#ifdef CONFIG_EXT4_MITIGATION_FALSE_SHARING + sizeof(struct ext4_inode_info), 128, +#else sizeof(struct ext4_inode_info), 0, +#endif (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD| SLAB_ACCOUNT), offsetof(struct ext4_inode_info, i_data),