Skip to content

Commit

Permalink
Revert "udp: avoid calling sock_def_readable() if possible"
Browse files Browse the repository at this point in the history
This reverts commit 612b1c0. On a
scenario with multiple threads blocking on a recvfrom(), we need to call
sock_def_readable() on every __udp_enqueue_schedule_skb() otherwise the
threads won't be woken up as __skb_wait_for_more_packets() is using
prepare_to_wait_exclusive().

Link: https://bugzilla.redhat.com/2308477
Fixes: 612b1c0 ("udp: avoid calling sock_def_readable() if possible")
Signed-off-by: Fernando Fernandez Mancera <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
ffmancera authored and kuba-moo committed Dec 4, 2024
1 parent cecc155 commit 3d501f5
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,6 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
struct sk_buff_head *list = &sk->sk_receive_queue;
int rmem, err = -ENOMEM;
spinlock_t *busy = NULL;
bool becomes_readable;
int size, rcvbuf;

/* Immediately drop when the receive queue is full.
Expand Down Expand Up @@ -1715,19 +1714,12 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
*/
sock_skb_set_dropcount(sk, skb);

becomes_readable = skb_queue_empty(list);
__skb_queue_tail(list, skb);
spin_unlock(&list->lock);

if (!sock_flag(sk, SOCK_DEAD)) {
if (becomes_readable ||
sk->sk_data_ready != sock_def_readable ||
READ_ONCE(sk->sk_peek_off) >= 0)
INDIRECT_CALL_1(sk->sk_data_ready,
sock_def_readable, sk);
else
sk_wake_async_rcu(sk, SOCK_WAKE_WAITD, POLL_IN);
}
if (!sock_flag(sk, SOCK_DEAD))
INDIRECT_CALL_1(sk->sk_data_ready, sock_def_readable, sk);

busylock_release(busy);
return 0;

Expand Down

0 comments on commit 3d501f5

Please sign in to comment.