Netdev List
 help / color / mirror / Atom feed
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>,
	 kuniyu@amazon.com
Subject: Re: [PATCH v3 net-next 2/2] udp_tunnel: use static call for GRO hooks when possible
Date: Tue, 11 Mar 2025 13:30:12 -0400	[thread overview]
Message-ID: <67d07324aff9a_2fa72c294d@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <8a47efb6-ee87-4287-b61b-eff37421609f@redhat.com>

Paolo Abeni wrote:
> On 3/11/25 3:51 AM, Willem de Bruijn wrote:
> > Paolo Abeni wrote:
> [...]
> >> +void udp_tunnel_update_gro_rcv(struct sock *sk, bool add)
> >> +{
> >> +	struct udp_tunnel_type_entry *cur = NULL, *avail = NULL;
> >> +	struct udp_sock *up = udp_sk(sk);
> >> +	int i, old_gro_type_nr;
> >> +
> >> +	if (!up->gro_receive)
> >> +		return;
> >> +
> >> +	mutex_lock(&udp_tunnel_gro_type_lock);
> >> +	for (i = 0; i < UDP_MAX_TUNNEL_TYPES; i++) {
> >> +		if (!refcount_read(&udp_tunnel_gro_types[i].count))
> > 
> > Optionally: && !avail, to fill the list from the front. And on delete
> > avoid gaps. For instance, like __fanout_link/__fanout_unlink.
> > 
> > Can stop sooner then. And list length is then implicit as i once found
> > the first [i].count == zero.
> > 
> > Then again, this list is always short. I can imagine you prefer to
> > leave as is.
> 
> I avoided optimizations for this slow path, to keep the code simpler.
> Thinking again about it, avoiding gaps will simplify/cleanup the code a
> bit (no need to lookup the enabled tunnel on deletion and to use `avail`
> on addition), so I'll do it.
> 
> Note that I'll still need to explicitly track the number of enabled
> tunnel types, as an easy way to disable the static call in the unlikely
> udp_tunnel_gro_type_nr == UDP_MAX_TUNNEL_TYPES event.
> 
> [...]
> >> +	if (udp_tunnel_gro_type_nr == 1) {
> >> +		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);
> >> +			}
> >> +		}
> >> +	} else if (old_gro_type_nr == 1) {
> >> +		static_branch_disable(&udp_tunnel_static_call);
> >> +		static_call_update(udp_tunnel_gro_rcv, dummy_gro_rcv);
> > 
> > These operations must not be reorderd, or dummy_gro_rcv might get hit.
> > 
> > If static calls are not configured, the last call is just a
> > WRITE_ONCE. Similar for static_branch_disable if !CONFIG_JUMP_LABEL.
> 
> When both construct are disabled, I think a wmb/rmb pair would be needed
> to ensure no reordering, and that in turn looks overkill. I think it
> would be better just drop the WARN_ONCE in dummy_gro_rcv().

SGTM, thanks.


  reply	other threads:[~2025-03-11 17:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 19:09 [PATCH v3 net-next 0/2] udp_tunnel: GRO optimizations Paolo Abeni
2025-03-10 19:09 ` [PATCH v3 net-next 1/2] udp_tunnel: create a fastpath GRO lookup Paolo Abeni
2025-03-11  2:32   ` Willem de Bruijn
2025-03-11 16:38     ` Paolo Abeni
2025-03-11 17:29       ` Willem de Bruijn
2025-03-11 17:37         ` Paolo Abeni
2025-03-11 17:55           ` Willem de Bruijn
2025-03-10 19:09 ` [PATCH v3 net-next 2/2] udp_tunnel: use static call for GRO hooks when possible Paolo Abeni
2025-03-11  2:51   ` Willem de Bruijn
2025-03-11 17:24     ` Paolo Abeni
2025-03-11 17:30       ` Willem de Bruijn [this message]
2025-03-11  5:49   ` Kuniyuki Iwashima

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=67d07324aff9a_2fa72c294d@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=kuniyu@amazon.com \
    --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