]> www.infradead.org Git - nvme.git/commit
fs: place f_ref to 3rd cache line in struct file to resolve false sharing
authorPan Deng <pan.deng@intel.com>
Fri, 28 Feb 2025 02:00:59 +0000 (10:00 +0800)
committerChristian Brauner <brauner@kernel.org>
Sat, 1 Mar 2025 10:02:35 +0000 (11:02 +0100)
commite249056c91a2f14ee40de2bf24cf72d8e68101f5
treef2d36ca11b706972a4a54dffd4ae26a31fc6e0e3
parentd3a194d95fc8d53539d555119048694a40833844
fs: place f_ref to 3rd cache line in struct file to resolve false sharing

When running syscall pread in a high core count system, f_ref contends
with the reading of f_mode, f_op, f_mapping, f_inode, f_flags in the
same cache line.

This change places f_ref to the 3rd cache line where fields are not
updated as frequently as the 1st cache line, and the contention is
grealy reduced according to tests. In addition, the size of file
object is kept in 3 cache lines.

This change has been tested with rocksdb benchmark readwhilewriting case
in 1 socket 64 physical core 128 logical core baremetal machine, with
build config CONFIG_RANDSTRUCT_NONE=y
Command:
./db_bench --benchmarks="readwhilewriting" --threads $cnt --duration 60
The throughput(ops/s) is improved up to ~21%.
=====
thread baseline compare
16  100%  +1.3%
32  100%  +2.2%
64  100%  +7.2%
128  100%  +20.9%

It was also tested with UnixBench: syscall, fsbuffer, fstime,
fsdisk cases that has been used for file struct layout tuning, no
regression was observed.

Signed-off-by: Pan Deng <pan.deng@intel.com>
Link: https://lore.kernel.org/r/20250228020059.3023375-1-pan.deng@intel.com
Tested-by: Lipeng Zhu <lipeng.zhu@intel.com>
Reviewed-by: Tianyou Li <tianyou.li@intel.com>
Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/fs.h