diff mbox series

[net-next,1/2] net/vsockmon: Leverage core stats allocator

Message ID 20240223115839.3572852-1-leitao@debian.org (mailing list archive)
State Accepted
Commit bcd53aff4d0cce9c4bedf345e6f896e35f2fd4c5
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] net/vsockmon: Leverage core stats allocator | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 957 this patch: 957
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 34 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-23--18-00 (tests: 1457)

Commit Message

Breno Leitao Feb. 23, 2024, 11:58 a.m. UTC
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 vsockmon driver and leverage the network
core allocation instead.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/vsockmon.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

Comments

Eric Dumazet Feb. 23, 2024, 1:09 p.m. UTC | #1
On Fri, Feb 23, 2024 at 12:58 PM Breno Leitao <leitao@debian.org> 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 vsockmon driver and leverage the network
> core allocation instead.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Eric Dumazet <edumazet@google.com>
Stefano Garzarella Feb. 26, 2024, 8:27 a.m. UTC | #2
On Fri, Feb 23, 2024 at 03:58:37AM -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 vsockmon driver and leverage the network
>core allocation instead.
>
>Signed-off-by: Breno Leitao <leitao@debian.org>
>---
> drivers/net/vsockmon.c | 16 +---------------
> 1 file changed, 1 insertion(+), 15 deletions(-)

Thanks for this patch!

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
>index b1bb1b04b664..a0b4dca36baf 100644
>--- a/drivers/net/vsockmon.c
>+++ b/drivers/net/vsockmon.c
>@@ -13,19 +13,6 @@
> #define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
> 		     sizeof(struct af_vsockmon_hdr))
>
>-static int vsockmon_dev_init(struct net_device *dev)
>-{
>-	dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
>-	if (!dev->lstats)
>-		return -ENOMEM;
>-	return 0;
>-}
>-
>-static void vsockmon_dev_uninit(struct net_device *dev)
>-{
>-	free_percpu(dev->lstats);
>-}
>-
> struct vsockmon {
> 	struct vsock_tap vt;
> };
>@@ -79,8 +66,6 @@ static int vsockmon_change_mtu(struct net_device *dev, int new_mtu)
> }
>
> static const struct net_device_ops vsockmon_ops = {
>-	.ndo_init = vsockmon_dev_init,
>-	.ndo_uninit = vsockmon_dev_uninit,
> 	.ndo_open = vsockmon_open,
> 	.ndo_stop = vsockmon_close,
> 	.ndo_start_xmit = vsockmon_xmit,
>@@ -112,6 +97,7 @@ static void vsockmon_setup(struct net_device *dev)
> 	dev->flags = IFF_NOARP;
>
> 	dev->mtu = DEFAULT_MTU;
>+	dev->pcpu_stat_type = NETDEV_PCPU_STAT_LSTATS;
> }
>
> static struct rtnl_link_ops vsockmon_link_ops __read_mostly = {
>-- 
>2.39.3
>
patchwork-bot+netdevbpf@kernel.org Feb. 27, 2024, 3:20 a.m. UTC | #3
Hello:

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

On Fri, 23 Feb 2024 03:58:37 -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/vsockmon: Leverage core stats allocator
    https://git.kernel.org/netdev/net-next/c/bcd53aff4d0c
  - [net-next,2/2] net/vsockmon: Do not set zeroed statistics
    https://git.kernel.org/netdev/net-next/c/3a25e212306c

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
index b1bb1b04b664..a0b4dca36baf 100644
--- a/drivers/net/vsockmon.c
+++ b/drivers/net/vsockmon.c
@@ -13,19 +13,6 @@ 
 #define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
 		     sizeof(struct af_vsockmon_hdr))
 
-static int vsockmon_dev_init(struct net_device *dev)
-{
-	dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
-	if (!dev->lstats)
-		return -ENOMEM;
-	return 0;
-}
-
-static void vsockmon_dev_uninit(struct net_device *dev)
-{
-	free_percpu(dev->lstats);
-}
-
 struct vsockmon {
 	struct vsock_tap vt;
 };
@@ -79,8 +66,6 @@  static int vsockmon_change_mtu(struct net_device *dev, int new_mtu)
 }
 
 static const struct net_device_ops vsockmon_ops = {
-	.ndo_init = vsockmon_dev_init,
-	.ndo_uninit = vsockmon_dev_uninit,
 	.ndo_open = vsockmon_open,
 	.ndo_stop = vsockmon_close,
 	.ndo_start_xmit = vsockmon_xmit,
@@ -112,6 +97,7 @@  static void vsockmon_setup(struct net_device *dev)
 	dev->flags = IFF_NOARP;
 
 	dev->mtu = DEFAULT_MTU;
+	dev->pcpu_stat_type = NETDEV_PCPU_STAT_LSTATS;
 }
 
 static struct rtnl_link_ops vsockmon_link_ops __read_mostly = {