Skip to content

Commit

Permalink
udp: relax atomic operation on sk->sk_rmem_alloc
Browse files Browse the repository at this point in the history
atomic_add_return() is more expensive than atomic_add()
and seems overkill in UDP rx fast path.

Signed-off-by: Eric Dumazet <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Eric Dumazet authored and kuba-moo committed Mar 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6055796 commit 6a1f12d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
@@ -1516,12 +1516,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
size = skb->truesize;
udp_set_dev_scratch(skb);

/* we drop only if the receive buf is full and the receive
* queue contains some other skb
*/
rmem = atomic_add_return(size, &sk->sk_rmem_alloc);
if (rmem > (size + (unsigned int)sk->sk_rcvbuf))
goto uncharge_drop;
atomic_add(size, &sk->sk_rmem_alloc);

spin_lock(&list->lock);
err = udp_rmem_schedule(sk, size);

0 comments on commit 6a1f12d

Please sign in to comment.