diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index b0425025151f926e6985182ed96e503841934307..bef053fc3ca27bf3f5aa46a1679717b3e4430c4f 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6236,6 +6236,7 @@ CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_EXT4_FS_SECURITY=y CONFIG_EXT4_ERROR_REPORT=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 5171aa50736b9a73943511beec15b38004f64c1a..4d20660de6616c5921149d14842d7a8fa2f8f232 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -7313,6 +7313,7 @@ CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_EXT4_FS_SECURITY=y CONFIG_EXT4_ERROR_REPORT=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 ae108d47ff00ff854cb3c23c2fe4dd6aafb7ea16..cd7f1e90c2372acf506032c095a7690b3c924ed7 100644 --- a/fs/ext4/Kconfig +++ b/fs/ext4/Kconfig @@ -125,3 +125,12 @@ config EXT4_ERROR_REPORT help Implement the ext3/ext4 file system error report. Report error to userspace by netlink + +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 aa4a314b461702552bcb1de51fba5c3fc754b336..210dcad8b82d10aae6aa596c720e32a1bb2cde7c 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1092,7 +1092,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 */ @@ -1105,6 +1107,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 395bed42846b09015b43dc5a2f23f34961f025cb..2c1f36c07ae10f36fd7c5e58a9eea11abe63639a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1436,7 +1436,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),