diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index 7701377126be064ebdb2686985c8c0443666455f..9edab914f39c4d2eafd6fc89ccb69d327afd62a7 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6211,6 +6211,7 @@ CONFIG_EXT4_USE_FOR_EXT2=y CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_EXT4_FS_SECURITY=y # CONFIG_EXT4_DEBUG is not set +CONFIG_EXT4_MITIGATION_FALSE_SHARING=y CONFIG_JBD2=m # CONFIG_JBD2_DEBUG is not set CONFIG_FS_MBCACHE=m diff --git a/arch/x86/configs/openeuler_defconfig b/arch/x86/configs/openeuler_defconfig index 62a8e5c1af11c1f05b659574dd71f2ceceb6dd25..831f829a25a97cd8e05ec010218f96e954c7be84 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -7308,6 +7308,7 @@ CONFIG_EXT4_USE_FOR_EXT2=y CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_EXT4_FS_SECURITY=y # CONFIG_EXT4_DEBUG is not set +CONFIG_EXT4_MITIGATION_FALSE_SHARING=y CONFIG_JBD2=m # CONFIG_JBD2_DEBUG is not set CONFIG_FS_MBCACHE=m 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),