]> Git Repo - linux.git/commit
nfs: avoid i_lock contention in nfs_clear_invalid_mapping
authorMike Snitzer <[email protected]>
Fri, 18 Oct 2024 21:15:41 +0000 (17:15 -0400)
committerAnna Schumaker <[email protected]>
Mon, 4 Nov 2024 15:24:19 +0000 (10:24 -0500)
commit867da60d463bb2a3e28c9235c487e56e96cffa00
tree2a4dac9fb4a8478814cbf0ec5df6e4de750c1544
parentbc2940869508b7b956a757a26d3b1ebf9546790e
nfs: avoid i_lock contention in nfs_clear_invalid_mapping

Multi-threaded buffered reads to the same file exposed significant
inode spinlock contention in nfs_clear_invalid_mapping().

Eliminate this spinlock contention by checking flags without locking,
instead using smp_rmb and smp_load_acquire accordingly, but then take
spinlock and double-check these inode flags.

Also refactor nfs_set_cache_invalid() slightly to use
smp_store_release() to pair with nfs_clear_invalid_mapping()'s
smp_load_acquire().

While this fix is beneficial for all multi-threaded buffered reads
issued by an NFS client, this issue was identified in the context of
surprisingly low LOCALIO performance with 4K multi-threaded buffered
read IO.  This fix dramatically speeds up LOCALIO performance:

before: read: IOPS=1583k, BW=6182MiB/s (6482MB/s)(121GiB/20002msec)
after:  read: IOPS=3046k, BW=11.6GiB/s (12.5GB/s)(232GiB/20001msec)

Fixes: 17dfeb911339 ("NFS: Fix races in nfs_revalidate_mapping")
Signed-off-by: Mike Snitzer <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
fs/nfs/inode.c
This page took 0.05361 seconds and 4 git commands to generate.