Skip to content

Commit 1af6622

Browse files
edumazetdavem330
authored andcommitted
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 <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: David Laight <[email protected]> Acked-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 462f855 commit 1af6622

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/socket.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,12 @@ static int ____sys_recvmsg(struct socket *sock, struct msghdr *msg_sys,
25592559

25602560
if (sock->file->f_flags & O_NONBLOCK)
25612561
flags |= MSG_DONTWAIT;
2562-
err = (nosec ? sock_recvmsg_nosec : sock_recvmsg)(sock, msg_sys, flags);
2562+
2563+
if (unlikely(nosec))
2564+
err = sock_recvmsg_nosec(sock, msg_sys, flags);
2565+
else
2566+
err = sock_recvmsg(sock, msg_sys, flags);
2567+
25632568
if (err < 0)
25642569
goto out;
25652570
len = err;

0 commit comments

Comments
 (0)