[net-next,2/2] net/vsockmon: Do not set zeroed statistics

Message ID 20240223115839.3572852-2-leitao@debian.org
State New
Headers
Series [net-next,1/2] net/vsockmon: Leverage core stats allocator |

Commit Message

Breno Leitao Feb. 23, 2024, 11:58 a.m. UTC
  Do not set rtnl_link_stats64 fields to zero, since they are zeroed
before ops->ndo_get_stats64 is called in core dev_get_stats() function.

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

Comments

Eric Dumazet Feb. 23, 2024, 1:08 p.m. UTC | #1
On Fri, Feb 23, 2024 at 12:58 PM Breno Leitao <leitao@debian.org> wrote:
>
> Do not set rtnl_link_stats64 fields to zero, since they are zeroed
> before ops->ndo_get_stats64 is called in core dev_get_stats() function.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Eric Dumazet <edumazet@google.com>
  
Stefano Garzarella Feb. 26, 2024, 8:31 a.m. UTC | #2
On Fri, Feb 23, 2024 at 03:58:38AM -0800, Breno Leitao wrote:
>Do not set rtnl_link_stats64 fields to zero, since they are zeroed
>before ops->ndo_get_stats64 is called in core dev_get_stats() function.
>
>Signed-off-by: Breno Leitao <leitao@debian.org>
>---
> drivers/net/vsockmon.c | 3 ---
> 1 file changed, 3 deletions(-)

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

>
>diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
>index a0b4dca36baf..a1ba5169ed5d 100644
>--- a/drivers/net/vsockmon.c
>+++ b/drivers/net/vsockmon.c
>@@ -46,9 +46,6 @@ static void
> vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
> {
> 	dev_lstats_read(dev, &stats->rx_packets, &stats->rx_bytes);
>-
>-	stats->tx_packets = 0;
>-	stats->tx_bytes = 0;
> }
>
> static int vsockmon_is_valid_mtu(int new_mtu)
>-- 
>2.39.3
>
  
Jason Xing Feb. 26, 2024, 9:27 a.m. UTC | #3
On Fri, Feb 23, 2024 at 7:59 PM Breno Leitao <leitao@debian.org> wrote:
>
> Do not set rtnl_link_stats64 fields to zero, since they are zeroed
> before ops->ndo_get_stats64 is called in core dev_get_stats() function.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>

Another similar codes that also can be changed later go like this:

diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
index 5e19a6839dea..9b205b152734 100644
--- a/drivers/net/nlmon.c
+++ b/drivers/net/nlmon.c
@@ -56,10 +56,8 @@ nlmon_get_stats64(struct net_device *dev, struct
rtnl_link_stats64 *stats)
        dev_lstats_read(dev, &packets, &bytes);

        stats->rx_packets = packets;
-       stats->tx_packets = 0;

        stats->rx_bytes = bytes;
-       stats->tx_bytes = 0;
 }

 static u32 always_on(struct net_device *dev)

> ---
>  drivers/net/vsockmon.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
> index a0b4dca36baf..a1ba5169ed5d 100644
> --- a/drivers/net/vsockmon.c
> +++ b/drivers/net/vsockmon.c
> @@ -46,9 +46,6 @@ static void
>  vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
>  {
>         dev_lstats_read(dev, &stats->rx_packets, &stats->rx_bytes);
> -
> -       stats->tx_packets = 0;
> -       stats->tx_bytes = 0;
>  }
>
>  static int vsockmon_is_valid_mtu(int new_mtu)
> --
> 2.39.3
>
>
  

Patch

diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
index a0b4dca36baf..a1ba5169ed5d 100644
--- a/drivers/net/vsockmon.c
+++ b/drivers/net/vsockmon.c
@@ -46,9 +46,6 @@  static void
 vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
 	dev_lstats_read(dev, &stats->rx_packets, &stats->rx_bytes);
-
-	stats->tx_packets = 0;
-	stats->tx_bytes = 0;
 }
 
 static int vsockmon_is_valid_mtu(int new_mtu)