Skip to content

Commit 18a5daf

Browse files
mjguzikbrauner
authored andcommitted
vfs: move d_lockref out of the area used by RCU lookup
Stock kernel scales worse than FreeBSD when doing a 20-way stat(2) on the same tmpfs-backed file. According to perf top: 38.09% lockref_put_return 26.08% lockref_get_not_dead 25.60% __d_lookup_rcu 0.89% clear_bhb_loop __d_lookup_rcu is participating in cacheline ping pong due to the embedded name sharing a cacheline with lockref. Moving it out resolves the problem: 41.50% lockref_put_return 41.03% lockref_get_not_dead 1.54% clear_bhb_loop benchmark (will-it-scale, Sapphire Rapids, tmpfs, ops/s): FreeBSD:7219334 before: 5038006 after: 7842883 (+55%) One minor remark: the 'after' result is unstable, fluctuating in the range ~7.8 mln to ~9 mln during different runs. Signed-off-by: Mateusz Guzik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 267574d commit 18a5daf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/linux/dcache.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,18 @@ struct dentry {
8989
struct inode *d_inode; /* Where the name belongs to - NULL is
9090
* negative */
9191
unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
92+
/* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */
9293

9394
/* Ref lookup also touches following */
94-
struct lockref d_lockref; /* per-dentry lock and refcount */
9595
const struct dentry_operations *d_op;
9696
struct super_block *d_sb; /* The root of the dentry tree */
9797
unsigned long d_time; /* used by d_revalidate */
9898
void *d_fsdata; /* fs-specific data */
99+
/* --- cacheline 2 boundary (128 bytes) --- */
100+
struct lockref d_lockref; /* per-dentry lock and refcount
101+
* keep separate from RCU lookup area if
102+
* possible!
103+
*/
99104

100105
union {
101106
struct list_head d_lru; /* LRU list */

0 commit comments

Comments
 (0)