Unverified Commit 7feb1eea authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!893 mitigatin cacheline false sharing

Merge Pull Request from: @zhangjialin11 
 
In the test of execl, shell1 and shell8 of UnixBench, L3 false sharing occurs between rwsem_try_write_lock_unqueued() and filemap_map_pages().

The offset between address_space.host and address_space.i_mmap_rwsem is 48. It may occur L3 false sharing. Their offsets in struct ext4_inode_info is 696 and 744, so when the address of ext4_inode_info after L3 aligned, it may occur L3 false sharing in the following condition:

[0x00 ~ 0x10] false sharing
[0x18 ~ 0x40] no false sharing
[0x48 ~ 0x80] false sharing

Change the offset of 'vfs_inode' from 320 to 360 in ext4_inode_info and make the address of ext4_inode_info L3 aligned, so the offset of host and i_mmap_rwsem in ext4_inode_info is changed to 736 and 784, it can make them in different L3 to avoid false sharing.

./Run -c 96 -i 3 execl

Before this patch:
System Benchmarks Partial Index              BASELINE       RESULT    INDEX
Execl Throughput                                 43.0      24238.0   5636.8
                                                                   ========
System Benchmarks Index Score (Partial Only)                         5636.8

After this patch:
System Benchmarks Partial Index              BASELINE       RESULT    INDEX
Execl Throughput                                 43.0      29363.7   6828.8
                                                                   ========
System Benchmarks Index Score (Partial Only)                         6828.8 
 
Link:https://gitee.com/openeuler/kernel/pulls/893

 

Reviewed-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 4ac8d141 137c85fc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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
+9 −0
Original line number Diff line number Diff line
@@ -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.
+5 −0
Original line number Diff line number Diff line
@@ -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;

+4 −0
Original line number Diff line number Diff line
@@ -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),