netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] udp: be less conservative with sock rmem accounting
@ 2016-12-02 16:35 Paolo Abeni
  2016-12-03 21:15 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Abeni @ 2016-12-02 16:35 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Jesper Dangaard Brouer

Before commit 850cbaddb52d ("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 <brouer@redhat.com>
Fixes: 850cbaddb52d ("udp: use it's own memory accounting schema")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv4/udp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index e1d0bf8..16d88ba 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1205,14 +1205,14 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
 	 * queue is full; always allow at least a packet
 	 */
 	rmem = atomic_read(&sk->sk_rmem_alloc);
-	if (rmem && (rmem + size > sk->sk_rcvbuf))
+	if (rmem > sk->sk_rcvbuf)
 		goto drop;
 
 	/* 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 > sk->sk_rcvbuf) && (rmem > size))
+	if (rmem > (size + sk->sk_rcvbuf))
 		goto uncharge_drop;
 
 	spin_lock(&list->lock);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] udp: be less conservative with sock rmem accounting
  2016-12-02 16:35 [PATCH net-next] udp: be less conservative with sock rmem accounting Paolo Abeni
@ 2016-12-03 21:15 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-12-03 21:15 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, brouer

From: Paolo Abeni <pabeni@redhat.com>
Date: Fri,  2 Dec 2016 17:35:49 +0100

> Before commit 850cbaddb52d ("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 <brouer@redhat.com>
> Fixes: 850cbaddb52d ("udp: use it's own memory accounting schema")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-03 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-02 16:35 [PATCH net-next] udp: be less conservative with sock rmem accounting Paolo Abeni
2016-12-03 21:15 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).