Skip to content

Commit 48b6190

Browse files
D-Wythedavem330
authored andcommitted
net/smc: Limit SMC visits when handshake workqueue congested
This patch intends to provide a mechanism to put constraint on SMC connections visit according to the pressure of SMC handshake process. At present, frequent visits will cause the incoming connections to be backlogged in SMC handshake queue, raise the connections established time. Which is quite unacceptable for those applications who base on short lived connections. There are two ways to implement this mechanism: 1. Put limitation after TCP established. 2. Put limitation before TCP established. In the first way, we need to wait and receive CLC messages that the client will potentially send, and then actively reply with a decline message, in a sense, which is also a sort of SMC handshake, affect the connections established time on its way. In the second way, the only problem is that we need to inject SMC logic into TCP when it is about to reply the incoming SYN, since we already do that, it's seems not a problem anymore. And advantage is obvious, few additional processes are required to complete the constraint. This patch use the second way. After this patch, connections who beyond constraint will not informed any SMC indication, and SMC will not be involved in any of its subsequent processes. Link: https://lore.kernel.org/all/1641301961-59331-1-git-send-email-alibuda@linux.alibaba.com/ Signed-off-by: D. Wythe <alibuda@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8270d9c commit 48b6190

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

include/linux/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ struct tcp_sock {
394394
bool is_mptcp;
395395
#endif
396396
#if IS_ENABLED(CONFIG_SMC)
397+
bool (*smc_hs_congested)(const struct sock *sk);
397398
bool syn_smc; /* SYN includes SMC */
398399
#endif
399400

net/ipv4/tcp_input.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6703,7 +6703,8 @@ static void tcp_openreq_init(struct request_sock *req,
67036703
ireq->ir_num = ntohs(tcp_hdr(skb)->dest);
67046704
ireq->ir_mark = inet_request_mark(sk, skb);
67056705
#if IS_ENABLED(CONFIG_SMC)
6706-
ireq->smc_ok = rx_opt->smc_ok;
6706+
ireq->smc_ok = rx_opt->smc_ok && !(tcp_sk(sk)->smc_hs_congested &&
6707+
tcp_sk(sk)->smc_hs_congested(sk));
67076708
#endif
67086709
}
67096710

net/smc/af_smc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,
103103
return NULL;
104104
}
105105

106+
static bool smc_hs_congested(const struct sock *sk)
107+
{
108+
const struct smc_sock *smc;
109+
110+
smc = smc_clcsock_user_data(sk);
111+
112+
if (!smc)
113+
return true;
114+
115+
if (workqueue_congested(WORK_CPU_UNBOUND, smc_hs_wq))
116+
return true;
117+
118+
return false;
119+
}
120+
106121
static struct smc_hashinfo smc_v4_hashinfo = {
107122
.lock = __RW_LOCK_UNLOCKED(smc_v4_hashinfo.lock),
108123
};
@@ -2311,6 +2326,8 @@ static int smc_listen(struct socket *sock, int backlog)
23112326

23122327
inet_csk(smc->clcsock->sk)->icsk_af_ops = &smc->af_ops;
23132328

2329+
tcp_sk(smc->clcsock->sk)->smc_hs_congested = smc_hs_congested;
2330+
23142331
rc = kernel_listen(smc->clcsock, backlog);
23152332
if (rc) {
23162333
smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;

0 commit comments

Comments
 (0)