[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <willemdebruijn.kernel.896e45dd59fc@gmail.com>
Date: Wed, 17 Sep 2025 15:14:04 -0400
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Eric Dumazet <edumazet@...gle.com>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
Willem de Bruijn <willemb@...gle.com>,
Kuniyuki Iwashima <kuniyu@...gle.com>,
David Ahern <dsahern@...nel.org>,
netdev@...r.kernel.org,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next 06/10] udp: update sk_rmem_alloc before busylock
acquisition
Eric Dumazet wrote:
> On Wed, Sep 17, 2025 at 8:01 AM Willem de Bruijn
> <willemdebruijn.kernel@...il.com> wrote:
> >
> > Eric Dumazet wrote:
> > > Avoid piling too many producers on the busylock
> > > by updating sk_rmem_alloc before busylock acquisition.
> > >
> > > Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> > > ---
> > > net/ipv4/udp.c | 7 +++++--
> > > 1 file changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> > > index edd846fee90ff7850356a5cb3400ce96856e5429..658ae87827991a78c25c2172d52e772c94ea217f 100644
> > > --- a/net/ipv4/udp.c
> > > +++ b/net/ipv4/udp.c
> > > @@ -1753,13 +1753,16 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
> > > if (rmem > (rcvbuf >> 1)) {
> > > skb_condense(skb);
> > > size = skb->truesize;
> > > + rmem = atomic_add_return(size, &sk->sk_rmem_alloc);
> > > + if (rmem > rcvbuf)
> > > + goto uncharge_drop;
> >
> > This does more than just reorganize code. Can you share some context
> > on the behavioral change?
>
> Sure : If we update sk_rmem_alloc sooner, before waiting 50usec+ on the busylock
> other cpus trying to push packets might see sk_rmem_alloc being too
> big already and exit early,
> before even trying to acquire the spinlock.
>
> Say you have many cpus coming there.
>
> Before the patch :
>
> They all spin on busylock, then update sk_rmem_alloc one at a time
> (while they hold busylock)
>
> After :
>
> They update sk_rmem_alloc :
> if too big, they immediately drop and return, no need to take any lock.
>
> If not too big, then they acquire the busylock.
I see. So this likely also overshoots the rcvbuf less?
As they currently all check against the sk_rcvbuf limit before
waiting (50usec+) on the busylock, and only update rmem and enqueue
after acquiring the lock. With no drop path at all (aside from
forward alloc).
Reviewed-by: Willem de Bruijn <willemb@...gle.com>
Powered by blists - more mailing lists