From: Eric Dumazet Date: Fri, 6 Dec 2019 17:38:36 +0000 (-0800) Subject: net: avoid an indirect call in ____sys_recvmsg() X-Git-Tag: v5.15~4919^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1af66221a66de080274540a5c481ddacbe3574d2;p=platform%2Fkernel%2Flinux-starfive.git net: avoid an indirect call in ____sys_recvmsg() CONFIG_RETPOLINE=y made indirect calls expensive. gcc seems to add an indirect call in ____sys_recvmsg(). Rewriting the code slightly makes sure to avoid this indirection. Alternative would be to not call sock_recvmsg() and instead use security_socket_recvmsg() and sock_recvmsg_nosec(), but this is less readable IMO. Signed-off-by: Eric Dumazet Cc: Paolo Abeni Cc: David Laight Acked-by: Paolo Abeni Signed-off-by: David S. Miller --- diff --git a/net/socket.c b/net/socket.c index ea28cbb..5af84d7 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2559,7 +2559,12 @@ static int ____sys_recvmsg(struct socket *sock, struct msghdr *msg_sys, if (sock->file->f_flags & O_NONBLOCK) flags |= MSG_DONTWAIT; - err = (nosec ? sock_recvmsg_nosec : sock_recvmsg)(sock, msg_sys, flags); + + if (unlikely(nosec)) + err = sock_recvmsg_nosec(sock, msg_sys, flags); + else + err = sock_recvmsg(sock, msg_sys, flags); + if (err < 0) goto out; len = err;