diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 7949b5d1663f1..5f8c20b67da26 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1251,10 +1251,8 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite); unlock_sock_fast(sk, slow); - if (noblock) - return -EAGAIN; - - /* starting over for a new packet */ + /* starting over for a new packet, but check if we need to yield */ + cond_resched(); msg->msg_flags &= ~MSG_TRUNC; goto try_again; } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index ef9052f8c90b6..2f99b12b717e3 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -451,10 +451,8 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, } unlock_sock_fast(sk, slow); - if (noblock) - return -EAGAIN; - - /* starting over for a new packet */ + /* starting over for a new packet, but check if we need to yield */ + cond_resched(); msg->msg_flags &= ~MSG_TRUNC; goto try_again; }