From: Rainer Weikusat Date: Thu, 26 Nov 2015 19:23:15 +0000 (+0000) Subject: unix: use wq_has_sleeper in unix_dgram_recvmsg X-Git-Tag: v5.15~13995^2~579 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77b75f4d8cf105b599beef38724f8171e557919d;p=platform%2Fkernel%2Flinux-starfive.git unix: use wq_has_sleeper in unix_dgram_recvmsg The current unix_dgram_recvmsg does a wake up for every received datagram. This seems wasteful as only SOCK_DGRAM client sockets in an n:1 association with a server socket will ever wait because of the associated condition. The patch below changes the function such that the wake up only happens if wq_has_sleeper indicates that someone actually wants to be notified. Testing with SOCK_SEQPACKET and SOCK_DGRAM socket seems to confirm that this is an improvment. Signed-Off-By: Rainer Weikusat Signed-off-by: David S. Miller --- diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index efb706e..ac011b9 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1914,8 +1914,10 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, goto out_unlock; } - wake_up_interruptible_sync_poll(&u->peer_wait, - POLLOUT | POLLWRNORM | POLLWRBAND); + if (wq_has_sleeper(&u->peer_wait)) + wake_up_interruptible_sync_poll(&u->peer_wait, + POLLOUT | POLLWRNORM | + POLLWRBAND); if (msg->msg_name) unix_copy_addr(msg, skb->sk);