Commit febe97ab authored by Litao Jiao's avatar Litao Jiao
Browse files

anolis: net/smc: double check whether accept queue is empty before schedule_timeout

anolis inclusion
from anolis-v5.10-134
commit 068f0d3b7c070a82c05a74ce6ec7240cad6a92c0
category: performance
bugzilla: https://gitee.com/openeuler/kernel/issues/I782PA
CVE: NA

Reference: https://gitee.com/anolis/hpn-cloud-kernel/commit/068f0d3b7c070a82c05a74ce6ec7240cad6a92c0



--------------------------------

ANBZ: #1742

Double check whether accept queue is empty before schedule_timeout.

Signed-off-by: default avatarGuangguan Wang <guangguan.wang@linux.alibaba.com>
Acked-by: default avatarTony Lu <tonylu@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/577
Link: https://gitee.com/anolis/cloud-kernel/pulls/906


Signed-off-by: default avatarLitao Jiao <jiaolitao@sangfor.com.cn>
parent a9b9689e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1250,6 +1250,11 @@ static void smc_accept_unlink(struct sock *sk)
	sock_put(sk); /* sock_hold in smc_accept_enqueue */
}

static inline bool smc_accept_queue_empty(struct sock *sk)
{
	return list_empty(&smc_sk(sk)->accept_q);
}

/* remove a sock from the accept queue to bind it to a new socket created
 * for a socket accept call from user space
 */
@@ -1969,6 +1974,7 @@ static int smc_accept(struct socket *sock, struct socket *new_sock,
			break;
		}
		release_sock(sk);
		if (smc_accept_queue_empty(sk))
			timeo = schedule_timeout(timeo);
		/* wakeup by sk_data_ready in smc_listen_work() */
		sched_annotate_sleep();