From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>
Subject: Re: [PATCH v2 net-next 1/2] udp_tunnel: create a fastpath GRO lookup.
Date: Sun, 09 Mar 2025 23:51:15 -0400 [thread overview]
Message-ID: <67ce61b338efd_20941f2949f@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <4bc191e2-b4f3-4e6b-8c9f-eaa67853aaae@redhat.com>
Paolo Abeni wrote:
> On 3/8/25 7:37 PM, Willem de Bruijn wrote:
> > Paolo Abeni wrote:
> >> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> >> index 2c0725583be39..054d4d4a8927f 100644
> >> --- a/net/ipv4/udp_offload.c
> >> +++ b/net/ipv4/udp_offload.c
> >> @@ -12,6 +12,38 @@
> >> #include <net/udp.h>
> >> #include <net/protocol.h>
> >> #include <net/inet_common.h>
> >> +#include <net/udp_tunnel.h>
> >> +
> >> +#if IS_ENABLED(CONFIG_NET_UDP_TUNNEL)
> >> +static DEFINE_SPINLOCK(udp_tunnel_gro_lock);
> >> +
> >> +void udp_tunnel_update_gro_lookup(struct net *net, struct sock *sk, bool add)
> >> +{
> >> + bool is_ipv6 = sk->sk_family == AF_INET6;
> >> + struct udp_sock *tup, *up = udp_sk(sk);
> >> + struct udp_tunnel_gro *udp_tunnel_gro;
> >> +
> >> + spin_lock(&udp_tunnel_gro_lock);
> >> + udp_tunnel_gro = &net->ipv4.udp_tunnel_gro[is_ipv6];
> >> + if (add)
> >> + hlist_add_head(&up->tunnel_list, &udp_tunnel_gro->list);
> >> + else
> >> + hlist_del_init(&up->tunnel_list);
> >> +
> >> + if (udp_tunnel_gro->list.first &&
> >> + !udp_tunnel_gro->list.first->next) {
> >> + tup = hlist_entry(udp_tunnel_gro->list.first, struct udp_sock,
> >> + tunnel_list);
> >> +
> >> + rcu_assign_pointer(udp_tunnel_gro->sk, (struct sock *)tup);
> >
> > If the targeted case is a single tunnel, is it worth maintaining the list?
> >
> > If I understand correctly, it is only there to choose a fall-back when the
> > current tup is removed. But complicates the code quite a bit.
>
> I'll try to answer the questions on both patches here.
>
> I guess in the end there is a relevant amount of personal preferences.
> Overall accounting is ~20 lines, IMHO it's not much.
In the next patch almost the entire body of udp_tunnel_update_gro_rcv
is there to maintain the refcount and list of tunnels.
Agreed that in the end it is subjective. Just that both patches
mention optimizing for the common case of a single tunnel type.
If you feel strongly, keep the list, of course.
Specific to the implementation
+ if (enabled && !old_enabled) {
Does enabled imply !old_enabled, once we get here? All paths
that do not modify udp_tunnel_gro_type_nr goto out.
+ for (i = 0; i < UDP_MAX_TUNNEL_TYPES; i++) {
+ cur = &udp_tunnel_gro_types[i];
+ if (refcount_read(&cur->count)) {
+ static_call_update(udp_tunnel_gro_rcv,
+ cur->gro_receive);
+ static_branch_enable(&udp_tunnel_static_call);
+ }
+ }
Can you use avail, rather than walk the list again?
> I think we should at least preserve the optimization when the relevant
> tunnel is deleted and re-created, and the minimal accounting required
> for that will drop just a bunch of lines from
> udp_tunnel_update_gro_lookup(), while keeping all the hooking.
>
> Additionally I think it would be surprising transiently applying some
> unusual configuration and as a side effect get lower performances up to
> the next reboot (lacking complete accounting).
>
> > Just curious: what does tup stand for?
>
> Tunnel Udp Pointer. Suggestion for better name welcome!
>
> Thanks,
>
> Paolo
>
next prev parent reply other threads:[~2025-03-10 3:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 18:13 [PATCH v2 net-next 0/2] udp_tunnel: GRO optimizations Paolo Abeni
2025-03-07 18:13 ` [PATCH v2 net-next 1/2] udp_tunnel: create a fastpath GRO lookup Paolo Abeni
2025-03-08 18:37 ` Willem de Bruijn
2025-03-09 15:55 ` Paolo Abeni
2025-03-10 3:51 ` Willem de Bruijn [this message]
2025-03-10 11:29 ` Paolo Abeni
2025-03-07 18:13 ` [PATCH v2 net-next 2/2] udp_tunnel: use static call for GRO hooks when possible Paolo Abeni
2025-03-08 18:40 ` Willem de Bruijn
2025-03-09 15:57 ` Paolo Abeni
2025-03-10 3:30 ` Willem de Bruijn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67ce61b338efd_20941f2949f@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).