Skip to content

Commit 2b877fc

Browse files
committed
SUNRPC: Reduce thread wake-up rate when receiving large RPC messages
With large NFS WRITE requests on TCP, I measured 5-10 thread wake- ups to receive each request. This is because the socket layer calls ->sk_data_ready() frequently, and each call triggers a thread wake-up. Each recvmsg() seems to pull in less than 100KB. Have the socket layer hold ->sk_data_ready() calls until the full incoming message has arrived to reduce the wake-up rate. Signed-off-by: Chuck Lever <[email protected]>
1 parent 89d2d9f commit 2b877fc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

net/sunrpc/svcsock.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,9 @@ static void svc_tcp_fragment_received(struct svc_sock *svsk)
10891089
/* If we have more data, signal svc_xprt_enqueue() to try again */
10901090
svsk->sk_tcplen = 0;
10911091
svsk->sk_marker = xdr_zero;
1092+
1093+
smp_wmb();
1094+
tcp_set_rcvlowat(svsk->sk_sk, 1);
10921095
}
10931096

10941097
/**
@@ -1178,10 +1181,17 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
11781181
goto err_delete;
11791182
if (len == want)
11801183
svc_tcp_fragment_received(svsk);
1181-
else
1184+
else {
1185+
/* Avoid more ->sk_data_ready() calls until the rest
1186+
* of the message has arrived. This reduces service
1187+
* thread wake-ups on large incoming messages. */
1188+
tcp_set_rcvlowat(svsk->sk_sk,
1189+
svc_sock_reclen(svsk) - svsk->sk_tcplen);
1190+
11821191
trace_svcsock_tcp_recv_short(&svsk->sk_xprt,
11831192
svc_sock_reclen(svsk),
11841193
svsk->sk_tcplen - sizeof(rpc_fraghdr));
1194+
}
11851195
goto err_noclose;
11861196
error:
11871197
if (len != -EAGAIN)

0 commit comments

Comments
 (0)