[PATCH v3 0/4] Reduce lock contention in the NFS client

Chuck Lever posted 4 patches 1 week, 2 days ago
fs/nfs/inode.c                             |  3 +-
include/linux/sunrpc/xprt.h                |  8 ++-
net/sunrpc/sched.c                         |  5 +-
net/sunrpc/svcsock.c                       |  6 +--
net/sunrpc/xprt.c                          | 85 ++++++++++++++++++------------
net/sunrpc/xprtrdma/rpc_rdma.c             | 14 ++---
net/sunrpc/xprtrdma/svc_rdma_backchannel.c |  8 +--
net/sunrpc/xprtsock.c                      | 18 +++----
8 files changed, 85 insertions(+), 62 deletions(-)
[PATCH v3 0/4] Reduce lock contention in the NFS client
Posted by Chuck Lever 1 week, 2 days ago
Under a 4KB NFSv3 workload on 100GbE RDMA, roughly 150 RPC worker
threads drive the client, and lock contention dominates its CPU
profile: up to 53% of non-idle cycles are spent in
native_queued_spin_lock_slowpath.

Three locks account for that: reserve_lock on every XID
allocation, queue_lock on every submit and completion, and the
unbound worker pool lock on every enqueue and dequeue for rpciod,
nfsiod, and xprtiod.

This series addresses the first two. v2 also moved the three
workqueues to the WQ_AFFN_SMT scope. Tim Menninger reported an
intermittent throughput regression on a 96-CPU two-socket
NFS/RDMA client and bisected it to the rpciod scope change [1].
The cause is still being worked out in that thread, so the scope
patches are withdrawn until it is understood. Until then, WQ_SYSFS
on all three workqueues lets an administrator set the scope from
user space.

[1] https://lore.kernel.org/linux-nfs/20260902204048.4100864-1-tmenninger@everpuredata.com/

---
Changes in v3:
- Drop the WQ_AFFN_SMT scope patches (Tim Menninger's regression report)
- Rebase on v7.3-rc2
- Link to v2: https://patch.msgid.link/20260902-performance-v2-0-b71c0c082f9d@kernel.org

Changes in v2:
- Fix send bvec use-after-free in xprt_request_dequeue_xprt() (sashiko)
- Replace the three workqueue exports with workqueue_set_affn_scope()
- Split the WQ_SYSFS patch into SUNRPC and NFS patches
- Drop v1 patch 2: async completions in the submitter can deadlock
- Correct the pool cost and SMT group wording in the scope patches
- Link to v1: https://patch.msgid.link/20260831-performance-v1-0-8d9fd9b67f96@kernel.org

---
Chuck Lever (4):
      SUNRPC: Use atomic_t for XID allocation
      SUNRPC: Split recv_lock out of xprt->queue_lock
      SUNRPC: Set WQ_SYSFS on rpciod and xprtiod
      NFS: Set WQ_SYSFS on nfsiod

 fs/nfs/inode.c                             |  3 +-
 include/linux/sunrpc/xprt.h                |  8 ++-
 net/sunrpc/sched.c                         |  5 +-
 net/sunrpc/svcsock.c                       |  6 +--
 net/sunrpc/xprt.c                          | 85 ++++++++++++++++++------------
 net/sunrpc/xprtrdma/rpc_rdma.c             | 14 ++---
 net/sunrpc/xprtrdma/svc_rdma_backchannel.c |  8 +--
 net/sunrpc/xprtsock.c                      | 18 +++----
 8 files changed, 85 insertions(+), 62 deletions(-)
---
base-commit: df2908090cda368b01ff43709f51890076c56157
change-id: 20260831-performance-e465e621c1c0

Best regards,
--  
Chuck Lever
Re: [PATCH v3 0/4] Reduce lock contention in the NFS client
Posted by Tim Menninger 1 week, 2 days ago
I built and tested v3 on the same 96-CPU dual-socket NFS/RDMA client
where I reproduced the v2 rpciod affinity regression.

With the WQ_AFFN_SMT scope changes removed, I can no longer reproduce
the throughput regression on my workload.

I also reviewed the remaining four patches and found no issues.

Reviewed-by: Tim Menninger <tmenninger@everpuredata.com>
Tested-by: Tim Menninger <tmenninger@everpuredata.com>
Re: [PATCH v3 0/4] Reduce lock contention in the NFS client
Posted by Jeff Layton 1 week, 2 days ago
On Tue, 2026-09-15 at 10:20 -0400, Chuck Lever wrote:
> Under a 4KB NFSv3 workload on 100GbE RDMA, roughly 150 RPC worker
> threads drive the client, and lock contention dominates its CPU
> profile: up to 53% of non-idle cycles are spent in
> native_queued_spin_lock_slowpath.
> 
> Three locks account for that: reserve_lock on every XID
> allocation, queue_lock on every submit and completion, and the
> unbound worker pool lock on every enqueue and dequeue for rpciod,
> nfsiod, and xprtiod.
> 
> This series addresses the first two. v2 also moved the three
> workqueues to the WQ_AFFN_SMT scope. Tim Menninger reported an
> intermittent throughput regression on a 96-CPU two-socket
> NFS/RDMA client and bisected it to the rpciod scope change [1].
> The cause is still being worked out in that thread, so the scope
> patches are withdrawn until it is understood. Until then, WQ_SYSFS
> on all three workqueues lets an administrator set the scope from
> user space.
> 
> [1] https://lore.kernel.org/linux-nfs/20260902204048.4100864-1-tmenninger@everpuredata.com/
> 
> ---
> Changes in v3:
> - Drop the WQ_AFFN_SMT scope patches (Tim Menninger's regression report)
> - Rebase on v7.3-rc2
> - Link to v2: https://patch.msgid.link/20260902-performance-v2-0-b71c0c082f9d@kernel.org
> 
> Changes in v2:
> - Fix send bvec use-after-free in xprt_request_dequeue_xprt() (sashiko)
> - Replace the three workqueue exports with workqueue_set_affn_scope()
> - Split the WQ_SYSFS patch into SUNRPC and NFS patches
> - Drop v1 patch 2: async completions in the submitter can deadlock
> - Correct the pool cost and SMT group wording in the scope patches
> - Link to v1: https://patch.msgid.link/20260831-performance-v1-0-8d9fd9b67f96@kernel.org
> 
> ---
> Chuck Lever (4):
>       SUNRPC: Use atomic_t for XID allocation
>       SUNRPC: Split recv_lock out of xprt->queue_lock
>       SUNRPC: Set WQ_SYSFS on rpciod and xprtiod
>       NFS: Set WQ_SYSFS on nfsiod
> 
>  fs/nfs/inode.c                             |  3 +-
>  include/linux/sunrpc/xprt.h                |  8 ++-
>  net/sunrpc/sched.c                         |  5 +-
>  net/sunrpc/svcsock.c                       |  6 +--
>  net/sunrpc/xprt.c                          | 85 ++++++++++++++++++------------
>  net/sunrpc/xprtrdma/rpc_rdma.c             | 14 ++---
>  net/sunrpc/xprtrdma/svc_rdma_backchannel.c |  8 +--
>  net/sunrpc/xprtsock.c                      | 18 +++----
>  8 files changed, 85 insertions(+), 62 deletions(-)
> ---
> base-commit: df2908090cda368b01ff43709f51890076c56157
> change-id: 20260831-performance-e465e621c1c0
> 
> Best regards,
> --  
> Chuck Lever

Nice, straightforward performance wins!

Reviewed-by: Jeff Layton <jlayton@kernel.org>