Skip to content

Commit 363dc73

Browse files
Paolo Abenidavem330
authored andcommitted
udp: be less conservative with sock rmem accounting
Before commit 850cbad ("udp: use it's own memory accounting schema"), the udp protocol allowed sk_rmem_alloc to grow beyond the rcvbuf by the whole current packet's truesize. After said commit we allow sk_rmem_alloc to exceed the rcvbuf only if the receive queue is empty. As reported by Jesper this cause a performance regression for some (small) values of rcvbuf. This commit is intended to fix the regression restoring the old handling of the rcvbuf limit. Reported-by: Jesper Dangaard Brouer <[email protected]> Fixes: 850cbad ("udp: use it's own memory accounting schema") Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 12efa1f commit 363dc73

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/udp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,14 +1205,14 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
12051205
* queue is full; always allow at least a packet
12061206
*/
12071207
rmem = atomic_read(&sk->sk_rmem_alloc);
1208-
if (rmem && (rmem + size > sk->sk_rcvbuf))
1208+
if (rmem > sk->sk_rcvbuf)
12091209
goto drop;
12101210

12111211
/* we drop only if the receive buf is full and the receive
12121212
* queue contains some other skb
12131213
*/
12141214
rmem = atomic_add_return(size, &sk->sk_rmem_alloc);
1215-
if ((rmem > sk->sk_rcvbuf) && (rmem > size))
1215+
if (rmem > (size + sk->sk_rcvbuf))
12161216
goto uncharge_drop;
12171217

12181218
spin_lock(&list->lock);

0 commit comments

Comments
 (0)