Skip to content

sunrpc: Reduce lock contention for NFSD TCP sockets

Chuck Lever linux-nfs 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 0 repliesNew
  2. v1 RFC7 patches 3 repliesSuperseded

Changes since RFC from the cover letter

- Drop the affinity scope patch
- Skip user memory hardening for kernel-to-kernel copies
- Avoid invoking wake_up when the receive is already running
- Refactor svc_tcp_receiver_thread() for legibility
- Do not set MSG_MORE during batched sends

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8sunrpc: Add XPT flags missing from SVC_XPRT_FLAG_LISTinclude/trace/events/sunrpc.h+3 -10 replies
2/8net: datagram: bypass usercopy checks for kernel iteratorsnet/core/datagram.c+13 -20 replies
3/8sunrpc: split svc_data_ready into protocol-specific callbacksinclude/trace/events/sunrpc.h net/sunrpc/svcsock.c+35 -70 replies
4/8sunrpc: add per-transport page recycling poolinclude/linux/sunrpc/svc.h include/linux/sunrpc/svc_xprt.h net/sunrpc/svc.c +1 more+197 -00 replies
5/8sunrpc: add dedicated TCP receiver threadinclude/linux/sunrpc/svcsock.h net/sunrpc/svcsock.c+498 -400 replies
6/8sunrpc: implement flat combining for TCP socket sendsinclude/linux/sunrpc/svcsock.h net/sunrpc/svcsock.c+158 -250 replies
7/8sunrpc: unify fore and backchannel server TCP send pathsinclude/linux/sunrpc/svcsock.h net/sunrpc/svcsock.c net/sunrpc/xprtsock.c+71 -670 replies
8/8sunrpc: Set explicit TCP socket buffer sizes for NFSDnet/sunrpc/svcsock.c+48 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/8] sunrpc: Reduce lock contention for NFSD TCP sockets

From: Chuck Lever <[email protected]>

High-throughput NFSD workloads exhibit significant lock contention on TCP connections. Worker threads compete for the socket lock during receives and serialize on xpt_mutex during sends, limiting scalability.

This series addresses both paths:

- Receive: A dedicated kernel thread per TCP connection owns all sock_recvmsg() calls and queues complete RPC messages for workers via lock-free llist. This eliminates socket lock contention among workers.

- Transmit: Flat combining allows one thread to send on behalf of multiple waiters. Threads enqueue requests; the mutex holder ("combiner") processes the batch, amortizing lock acquisition and enabling TCP segment coalescing via MSG_MORE.

Supporting changes include a page recycling pool for receive buffers, and explicit TCP buffer sizing for high bandwidth-delay product networks.

Base commit: v6.19
URL: https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=svctcp-next

---

Changes since RFC:
- Drop the affinity scope patch
- Skip user memory hardening for kernel-to-kernel copies
- Avoid invoking wake_up when the receive is already running
- Refactor svc_tcp_receiver_thread() for legibility
- Do not set MSG_MORE during batched sends

Chuck Lever (8):
sunrpc: Add XPT flags missing from SVC_XPRT_FLAG_LIST
net: datagram: bypass usercopy checks for kernel iterators
sunrpc: split svc_data_ready into protocol-specific callbacks
sunrpc: add per-transport page recycling pool
sunrpc: add dedicated TCP receiver thread
sunrpc: implement flat combining for TCP socket sends
sunrpc: unify fore and backchannel server TCP send paths
sunrpc: Set explicit TCP socket buffer sizes for NFSD

 include/linux/sunrpc/svc.h      |   1 +
 include/linux/sunrpc/svc_xprt.h |  32 ++
 include/linux/sunrpc/svcsock.h  |  40 ++
 include/trace/events/sunrpc.h   |   7 +-
 net/core/datagram.c             |  15 +-
 net/sunrpc/svc.c                |  13 +
 net/sunrpc/svc_xprt.c           | 151 ++++++
 net/sunrpc/svcsock.c            | 802 +++++++++++++++++++++++++++++---
 net/sunrpc/xprtsock.c           |  60 +--
 9 files changed, 999 insertions(+), 122 deletions(-)
Signature · 1 line
2.52.0