2024-02-29 17:08:07

by Breno Leitao

[permalink] [raw]
Subject: [PATCH net-next 1/2] net: bareudp: Do not allocate stats in the driver

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 bareudp driver and leverage the network
core allocation.

Signed-off-by: Breno Leitao <[email protected]>
---
drivers/net/bareudp.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
index 4db6122c9b43..27408f0b93d6 100644
--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -194,15 +194,10 @@ static int bareudp_init(struct net_device *dev)
struct bareudp_dev *bareudp = netdev_priv(dev);
int err;

- dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
- if (!dev->tstats)
- return -ENOMEM;
-
err = gro_cells_init(&bareudp->gro_cells, dev);
- if (err) {
- free_percpu(dev->tstats);
+ if (err)
return err;
- }
+
return 0;
}

@@ -211,7 +206,6 @@ static void bareudp_uninit(struct net_device *dev)
struct bareudp_dev *bareudp = netdev_priv(dev);

gro_cells_destroy(&bareudp->gro_cells);
- free_percpu(dev->tstats);
}

static struct socket *bareudp_create_sock(struct net *net, __be16 port)
@@ -567,6 +561,7 @@ static void bareudp_setup(struct net_device *dev)
netif_keep_dst(dev);
dev->priv_flags |= IFF_NO_QUEUE;
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
+ dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
}

static int bareudp_validate(struct nlattr *tb[], struct nlattr *data[],
--
2.43.0



2024-02-29 17:08:17

by Breno Leitao

[permalink] [raw]
Subject: [PATCH net-next 2/2] net: bareudp: Remove generic .ndo_get_stats64

Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is
configured") moved the callback to dev_get_tstats64() to net core, so,
unless the driver is doing some custom stats collection, it does not
need to set .ndo_get_stats64.

Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it
doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64
function pointer.

Signed-off-by: Breno Leitao <[email protected]>
---
drivers/net/bareudp.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
index 27408f0b93d6..339db6e4a1d5 100644
--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -523,7 +523,6 @@ static const struct net_device_ops bareudp_netdev_ops = {
.ndo_open = bareudp_open,
.ndo_stop = bareudp_stop,
.ndo_start_xmit = bareudp_xmit,
- .ndo_get_stats64 = dev_get_tstats64,
.ndo_fill_metadata_dst = bareudp_fill_metadata_dst,
};

--
2.43.0


2024-03-01 16:00:37

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH net-next 1/2] net: bareudp: Do not allocate stats in the driver

On Thu, Feb 29, 2024 at 09:04:23AM -0800, 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 bareudp driver and leverage the network
> core allocation.
>
> Signed-off-by: Breno Leitao <[email protected]>

Reviewed-by: Simon Horman <[email protected]>


2024-03-01 16:08:24

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH net-next 2/2] net: bareudp: Remove generic .ndo_get_stats64

On Thu, Feb 29, 2024 at 09:04:24AM -0800, Breno Leitao wrote:
> Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is
> configured") moved the callback to dev_get_tstats64() to net core, so,
> unless the driver is doing some custom stats collection, it does not
> need to set .ndo_get_stats64.
>
> Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it
> doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64
> function pointer.
>
> Signed-off-by: Breno Leitao <[email protected]>

Reviewed-by: Simon Horman <[email protected]>


2024-03-04 09:00:56

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next 1/2] net: bareudp: Do not allocate stats in the driver

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <[email protected]>:

On Thu, 29 Feb 2024 09:04:23 -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: bareudp: Do not allocate stats in the driver
https://git.kernel.org/netdev/net-next/c/6f355bbb5ca3
- [net-next,2/2] net: bareudp: Remove generic .ndo_get_stats64
https://git.kernel.org/netdev/net-next/c/4ab597d29621

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