netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>
Subject: Re: [PATCH net-next v3] net: introduce per netns packet chains
Date: Thu, 20 Mar 2025 16:03:48 +0100	[thread overview]
Message-ID: <Z9wuVAyFYcziY4-D@krikkit> (raw)
In-Reply-To: <2b6ce88cb7da4d74853cc36d7de4b1b11a7362e5.1742401226.git.pabeni@redhat.com>

2025-03-19, 17:24:03 +0100, Paolo Abeni wrote:
> Currently network taps unbound to any interface are linked in the
> global ptype_all list, affecting the performance in all the network
> namespaces.
> 
> Add per netns ptypes chains, so that in the mentioned case only
> the netns owning the packet socket(s) is affected.
> 
> While at that drop the global ptype_all list: no in kernel user
> registers a tap on "any" type without specifying either the target
> device or the target namespace (and IMHO doing that would not make
> any sense).
> 
> Note that this adds a conditional in the fast path (to check for
> per netns ptype_specific list) and increases the dataset size by
> a cacheline (owing the per netns lists).
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>


Just two tiny nits:


>  /**
> - * dev_nit_active - return true if any network interface taps are in use
> + * dev_nit_active_rcu - return true if any network interface taps are in use
> + *
> + * The caller must hold the RCU lock
>   *
>   * @dev: network device to check for the presence of taps
>   */
> -bool dev_nit_active(struct net_device *dev)
> +bool dev_nit_active_rcu(struct net_device *dev)

I guess that would have been a good time to make dev const? (same in
the new wrapper)

>  {
> -	return !list_empty(&net_hotdata.ptype_all) ||
> +	/* Callers may hold either RCU or RCU BH lock */
> +	WARN_ON_ONCE(!rcu_read_lock_held() && !rcu_read_lock_bh_held());
> +
> +	return !list_empty(&dev_net(dev)->ptype_all) ||
>  	       !list_empty(&dev->ptype_all);
>  }

[...]
> @@ -5830,6 +5851,14 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
>  		deliver_ptype_list_skb(skb, &pt_prev, orig_dev, type,
>  				       &ptype_base[ntohs(type) &
>  						   PTYPE_HASH_MASK]);
> +
> +		/* orig_dev and skb->dev could belong to different netns;
> +		 * Even is such case we need to traverse only the list

I think there's a typo here: "Even in"

-- 
Sabrina

  reply	other threads:[~2025-03-20 15:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19 16:24 [PATCH net-next v3] net: introduce per netns packet chains Paolo Abeni
2025-03-20 15:03 ` Sabrina Dubroca [this message]
2025-03-20 18:14   ` Paolo Abeni

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=Z9wuVAyFYcziY4-D@krikkit \
    --to=sd@queasysnail.net \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --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).