bridge.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver
@ 2024-02-27 18:23 Breno Leitao
  2024-02-27 18:23 ` [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails Breno Leitao
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Breno Leitao @ 2024-02-27 18:23 UTC (permalink / raw)
  To: kuba, davem, pabeni, edumazet, Roopa Prabhu, Nikolay Aleksandrov
  Cc: netdev, linux-kernel, horms, open list:ETHERNET BRIDGE

With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
convert veth & vrf"), stats allocation could be done on net core
instead of this driver.

With this new approach, the driver doesn't have to bother with error
handling (allocation failure checking, making sure free happens in the
right spot, etc). This is core responsibility now.

Remove the allocation in the bridge driver and leverage the network
core allocation.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/bridge/br_device.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 874cec75a818..4f636f7b0555 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -113,26 +113,18 @@ static int br_dev_init(struct net_device *dev)
 	struct net_bridge *br = netdev_priv(dev);
 	int err;
 
-	dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
-	if (!dev->tstats)
-		return -ENOMEM;
-
 	err = br_fdb_hash_init(br);
-	if (err) {
-		free_percpu(dev->tstats);
+	if (err)
 		return err;
-	}
 
 	err = br_mdb_hash_init(br);
 	if (err) {
-		free_percpu(dev->tstats);
 		br_fdb_hash_fini(br);
 		return err;
 	}
 
 	err = br_vlan_init(br);
 	if (err) {
-		free_percpu(dev->tstats);
 		br_mdb_hash_fini(br);
 		br_fdb_hash_fini(br);
 		return err;
@@ -140,7 +132,6 @@ static int br_dev_init(struct net_device *dev)
 
 	err = br_multicast_init_stats(br);
 	if (err) {
-		free_percpu(dev->tstats);
 		br_vlan_flush(br);
 		br_mdb_hash_fini(br);
 		br_fdb_hash_fini(br);
@@ -159,7 +150,6 @@ static void br_dev_uninit(struct net_device *dev)
 	br_vlan_flush(br);
 	br_mdb_hash_fini(br);
 	br_fdb_hash_fini(br);
-	free_percpu(dev->tstats);
 }
 
 static int br_dev_open(struct net_device *dev)
@@ -496,6 +486,7 @@ void br_dev_setup(struct net_device *dev)
 	dev->hw_features = COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
 			   NETIF_F_HW_VLAN_STAG_TX;
 	dev->vlan_features = COMMON_FEATURES;
+	dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
 
 	br->dev = dev;
 	spin_lock_init(&br->lock);
-- 
2.43.0


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

* [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails
  2024-02-27 18:23 [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Breno Leitao
@ 2024-02-27 18:23 ` Breno Leitao
  2024-02-27 19:02   ` Nikolay Aleksandrov
  2024-02-27 19:02 ` [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Nikolay Aleksandrov
  2024-02-29  4:20 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Breno Leitao @ 2024-02-27 18:23 UTC (permalink / raw)
  To: kuba, davem, pabeni, edumazet, Roopa Prabhu, Nikolay Aleksandrov
  Cc: netdev, linux-kernel, horms, open list:ETHERNET BRIDGE

If br_multicast_init_stats() fails, there is no need to set lockdep
classes. Just return from the error path.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/bridge/br_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 4f636f7b0555..c366ccc8b3db 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -135,10 +135,11 @@ static int br_dev_init(struct net_device *dev)
 		br_vlan_flush(br);
 		br_mdb_hash_fini(br);
 		br_fdb_hash_fini(br);
+		return err;
 	}
 
 	netdev_lockdep_set_classes(dev);
-	return err;
+	return 0;
 }
 
 static void br_dev_uninit(struct net_device *dev)
-- 
2.43.0


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

* Re: [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver
  2024-02-27 18:23 [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Breno Leitao
  2024-02-27 18:23 ` [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails Breno Leitao
@ 2024-02-27 19:02 ` Nikolay Aleksandrov
  2024-02-29  4:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2024-02-27 19:02 UTC (permalink / raw)
  To: Breno Leitao, kuba, davem, pabeni, edumazet, Roopa Prabhu
  Cc: netdev, linux-kernel, horms, open list:ETHERNET BRIDGE

On 2/27/24 20:23, Breno Leitao wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> Remove the allocation in the bridge driver and leverage the network
> core allocation.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>   net/bridge/br_device.c | 13 ++-----------
>   1 file changed, 2 insertions(+), 11 deletions(-)
> 

Acked-by: Nikolay Aleksandrov <razor@blackwall.org>


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

* Re: [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails
  2024-02-27 18:23 ` [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails Breno Leitao
@ 2024-02-27 19:02   ` Nikolay Aleksandrov
  0 siblings, 0 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2024-02-27 19:02 UTC (permalink / raw)
  To: Breno Leitao, kuba, davem, pabeni, edumazet, Roopa Prabhu
  Cc: netdev, linux-kernel, horms, open list:ETHERNET BRIDGE

On 2/27/24 20:23, Breno Leitao wrote:
> If br_multicast_init_stats() fails, there is no need to set lockdep
> classes. Just return from the error path.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>   net/bridge/br_device.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
> index 4f636f7b0555..c366ccc8b3db 100644
> --- a/net/bridge/br_device.c
> +++ b/net/bridge/br_device.c
> @@ -135,10 +135,11 @@ static int br_dev_init(struct net_device *dev)
>   		br_vlan_flush(br);
>   		br_mdb_hash_fini(br);
>   		br_fdb_hash_fini(br);
> +		return err;
>   	}
>   
>   	netdev_lockdep_set_classes(dev);
> -	return err;
> +	return 0;
>   }
>   
>   static void br_dev_uninit(struct net_device *dev)

Please send them as separate patches next time. These are not related 
and shouldn't be a part of a set.

Acked-by: Nikolay Aleksandrov <razor@blackwall.org>

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

* Re: [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver
  2024-02-27 18:23 [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Breno Leitao
  2024-02-27 18:23 ` [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails Breno Leitao
  2024-02-27 19:02 ` [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Nikolay Aleksandrov
@ 2024-02-29  4:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-29  4:20 UTC (permalink / raw)
  To: Breno Leitao
  Cc: kuba, davem, pabeni, edumazet, roopa, razor, netdev,
	linux-kernel, horms, bridge

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 27 Feb 2024 10:23:36 -0800 you wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: bridge: Do not allocate stats in the driver
    https://git.kernel.org/netdev/net-next/c/d35150c79ffc
  - [net-next,2/2] net: bridge: Exit if multicast_init_stats fails
    https://git.kernel.org/netdev/net-next/c/82a48affb36f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-02-29  4:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 18:23 [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Breno Leitao
2024-02-27 18:23 ` [PATCH net-next 2/2] net: bridge: Exit if multicast_init_stats fails Breno Leitao
2024-02-27 19:02   ` Nikolay Aleksandrov
2024-02-27 19:02 ` [PATCH net-next 1/2] net: bridge: Do not allocate stats in the driver Nikolay Aleksandrov
2024-02-29  4:20 ` patchwork-bot+netdevbpf

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).