From: Wen Gu <guwen@xxxxxxxxxxxxxxxxx> A socket_wq mismatch issue may occur because of fallback. When use SMC to replace TCP, applications add an epoll entry into SMC socket's wq, but kernel uses clcsock's wq instead of SMC socket's wq once fallback occurs, which means the application's epoll fd dosen't work anymore. For example: server: nginx -g 'daemon off;' client: smc_run wrk -c 1 -t 1 -d 5 http://11.200.15.93/index.html Running 5s test @ http://11.200.15.93/index.html 1 threads and 1 connections Thread Stats Avg Stdev Max +/- Stdev Latency 0.00us 0.00us 0.00us -nan% Req/Sec 0.00 0.00 0.00 -nan% 0 requests in 5.00s, 0.00B read Requests/sec: 0.00 Transfer/sec: 0.00B This patch fixes this issue by using clcsock's wq regardless of whether fallback occurs. Reported-by: Jacob Qi <jacob.qi@xxxxxxxxxxxxxxxxx> Signed-off-by: Wen Gu <guwen@xxxxxxxxxxxxxxxxx> Reviewed-by: Tony Lu <tonylu@xxxxxxxxxxxxxxxxx> --- net/smc/af_smc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 78b663dbfa1f..3b7ec0abff52 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -546,6 +546,10 @@ static void smc_switch_to_fallback(struct smc_sock *smc, int reason_code) { smc->use_fallback = true; smc->fallback_rsn = reason_code; + + /* clcsock's sock uses back to clcsock->wq, see also smc_create() */ + rcu_assign_pointer(smc->clcsock->sk->sk_wq, &smc->clcsock->wq); + smc_stat_fallback(smc); if (smc->sk.sk_socket && smc->sk.sk_socket->file) { smc->clcsock->file = smc->sk.sk_socket->file; @@ -1972,6 +1976,10 @@ static int smc_accept(struct socket *sock, struct socket *new_sock, if (rc) goto out; + /* new smc sock uses clcsock's wq. see also smc_create() */ + if (!smc_sk(nsk)->use_fallback) + rcu_assign_pointer(nsk->sk_wq, &smc_sk(nsk)->clcsock->wq); + if (lsmc->sockopt_defer_accept && !(flags & O_NONBLOCK)) { /* wait till data arrives on the socket */ timeo = msecs_to_jiffies(lsmc->sockopt_defer_accept * @@ -2108,6 +2116,9 @@ static __poll_t smc_poll(struct file *file, struct socket *sock, mask = smc->clcsock->ops->poll(file, smc->clcsock, wait); sk->sk_err = smc->clcsock->sk->sk_err; } else { + /* use clcsock->wq in sock_poll_wait(), see also smc_create() */ + sock = smc->clcsock; + if (sk->sk_state != SMC_CLOSED) sock_poll_wait(file, sock, wait); if (sk->sk_err) @@ -2505,6 +2516,10 @@ static int smc_create(struct net *net, struct socket *sock, int protocol, smc->sk.sk_sndbuf = max(smc->clcsock->sk->sk_sndbuf, SMC_BUF_MIN_SIZE); smc->sk.sk_rcvbuf = max(smc->clcsock->sk->sk_rcvbuf, SMC_BUF_MIN_SIZE); + /* In case smc fallbacks to tcp, smc's sock will use clcsock's wq in advance */ + rcu_assign_pointer(sk->sk_wq, &smc->clcsock->wq); + rcu_assign_pointer(smc->clcsock->sk->sk_wq, &smc->sk.sk_socket->wq); + out: return rc; } -- 2.19.1.6.gb485710b