Message ID | 20240202083304.10995-1-JonasZhou-oc@zhaoxin.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fs/address_space: move i_mmap_rwsem to mitigate a false sharing with i_mmap. | expand |
On Fri, Feb 02, 2024 at 04:33:04PM +0800, JonasZhou-oc wrote: > From: JonasZhou <JonasZhou@zhaoxin.com> > > In the struct address_space, there is a 32-byte gap between i_mmap > and i_mmap_rwsem. Due to the alignment of struct address_space > variables to 8 bytes, in certain situations, i_mmap and i_mmap_rwsem > may end up in the same CACHE line. > > While running Unixbench/execl, we observe high false sharing issues > when accessing i_mmap against i_mmap_rwsem. We move i_mmap_rwsem > after i_private_list, ensuring a 64-byte gap between i_mmap and > i_mmap_rwsem. > > For Intel Silver machines (2 sockets) using kernel v6.8 rc-2, the score > of Unixbench/execl improves by ~3.94%, and the score of Unixbench/shell > improves by ~3.26%. Looks sane.
On Fri, 02 Feb 2024 16:33:04 +0800, JonasZhou-oc wrote: > In the struct address_space, there is a 32-byte gap between i_mmap > and i_mmap_rwsem. Due to the alignment of struct address_space > variables to 8 bytes, in certain situations, i_mmap and i_mmap_rwsem > may end up in the same CACHE line. > > While running Unixbench/execl, we observe high false sharing issues > when accessing i_mmap against i_mmap_rwsem. We move i_mmap_rwsem > after i_private_list, ensuring a 64-byte gap between i_mmap and > i_mmap_rwsem. > > [...] Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.misc [1/1] fs/address_space: move i_mmap_rwsem to mitigate a false sharing with i_mmap. https://git.kernel.org/vfs/vfs/c/2a42e144dd0b
diff --git a/include/linux/fs.h b/include/linux/fs.h index ed5966a70495..2d6ccde5d1be 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -482,10 +482,10 @@ struct address_space { pgoff_t writeback_index; const struct address_space_operations *a_ops; unsigned long flags; - struct rw_semaphore i_mmap_rwsem; errseq_t wb_err; spinlock_t i_private_lock; struct list_head i_private_list; + struct rw_semaphore i_mmap_rwsem; void * i_private_data; } __attribute__((aligned(sizeof(long)))) __randomize_layout; /*