diff mbox series

sunrpc: allow SOMAXCONN backlogged TCP connections

Message ID 20250417-svc-somaxconn-v1-1-ff5955cc9f45@kernel.org (mailing list archive)
State New
Headers show
Series sunrpc: allow SOMAXCONN backlogged TCP connections | expand

Commit Message

Jeff Layton April 17, 2025, 6:54 p.m. UTC
The connection backlog passed to listen() denotes the number of
connections that are fully established, but that have not yet been
accept()ed. If the amount goes above that level, new connection requests
will be dropped on the floor until the value goes down. If all the knfsd
threads are bogged down in (e.g.) disk I/O, new connection attempts can
stall because of this.

For the same rationale that Trond points out in the userland patch [1],
ensure that svc_xprt sockets created by the kernel allow SOMAXCONN
(4096) backlogged connections instead of the 64 that they do today.

[1]: https://lore.kernel.org/linux-nfs/20240308180223.2965601-1-trond.myklebust@hammerspace.com/

Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
The backlog was set at 5 in v2.4.0. Neil changed it to 64 in 2002, and
it's been set to that ever since.

This is particularly needed for servers that are started via the netlink
interface, so we don't regress the behavior that Trond's patch fixed
with the sockfd-passing interface.
---
 net/sunrpc/svcsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 01bc8a703933a0b7b76e6d6fbc58e4f1d5b64ae5
change-id: 20250417-svc-somaxconn-b6413c1d39bf

Best regards,

Comments

Chuck Lever April 18, 2025, 2 p.m. UTC | #1
From: Chuck Lever <chuck.lever@oracle.com>

On Thu, 17 Apr 2025 14:54:36 -0400, Jeff Layton wrote:
> The connection backlog passed to listen() denotes the number of
> connections that are fully established, but that have not yet been
> accept()ed. If the amount goes above that level, new connection requests
> will be dropped on the floor until the value goes down. If all the knfsd
> threads are bogged down in (e.g.) disk I/O, new connection attempts can
> stall because of this.
> 
> [...]

Applied to nfsd-testing, thanks!

[1/1] sunrpc: allow SOMAXCONN backlogged TCP connections
      commit: 1fe4a78475a5203a9ee1d9ede1bc2043cb505382

--
Chuck Lever
diff mbox series

Patch

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 72e5a01df3d352582a5c25e0b8081a041e3792ee..60f2883268faf15b8e01a5d12d67a5d01b278a5e 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1542,7 +1542,7 @@  static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
 
 	if (protocol == IPPROTO_TCP) {
 		sk_net_refcnt_upgrade(sock->sk);
-		if ((error = kernel_listen(sock, 64)) < 0)
+		if ((error = kernel_listen(sock, SOMAXCONN)) < 0)
 			goto bummer;
 	}