mbox series

[net-next,0/5] net: add and use dev_get_tstats64

Message ID 25c7e008-c3fb-9fcd-f518-5d36e181c0cb@gmail.com
Headers show
Series net: add and use dev_get_tstats64 | expand

Message

Heiner Kallweit Nov. 1, 2020, 12:33 p.m. UTC
It's a frequent pattern to use netdev->stats for the less frequently
accessed counters and per-cpu counters for the frequently accessed
counters (rx/tx bytes/packets). Add a default ndo_get_stats64()
implementation for this use case. Subsequently switch more drivers
to use this pattern.

Heiner Kallweit (5):
  net: core: add dev_get_tstats64 as a ndo_get_stats64 implementation
  net: make ip_tunnel_get_stats64 an alias for dev_get_tstats64
  ip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback
  net: dsa: use net core stats64 handling
  tun: switch to net core provided statistics counters

 drivers/net/tun.c         | 127 ++++++++++----------------------------
 include/linux/netdevice.h |   1 +
 include/net/ip_tunnels.h  |   4 +-
 net/core/dev.c            |  15 +++++
 net/dsa/dsa.c             |   7 +--
 net/dsa/dsa_priv.h        |   2 -
 net/dsa/slave.c           |  29 +++------
 net/ipv4/ip_tunnel_core.c |   9 ---
 net/ipv6/ip6_tunnel.c     |  32 +---------
 9 files changed, 58 insertions(+), 168 deletions(-)

Comments

Florian Fainelli Nov. 2, 2020, 9:09 p.m. UTC | #1
On 11/1/2020 4:34 AM, Heiner Kallweit wrote:
> It's a frequent pattern to use netdev->stats for the less frequently

> accessed counters and per-cpu counters for the frequently accessed

> counters (rx/tx bytes/packets). Add a default ndo_get_stats64()

> implementation for this use case.

> 

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>


Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

-- 
Florian
Florian Fainelli Nov. 2, 2020, 9:13 p.m. UTC | #2
On 11/1/2020 4:37 AM, Heiner Kallweit wrote:
> Use netdev->tstats instead of a member of dsa_slave_priv for storing

> a pointer to the per-cpu counters. This allows us to use core

> functionality for statistics handling.

> 

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>


Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

-- 
Florian
Vladimir Oltean Nov. 2, 2020, 9:22 p.m. UTC | #3
On Sun, Nov 01, 2020 at 01:37:03PM +0100, Heiner Kallweit wrote:
> Use netdev->tstats instead of a member of dsa_slave_priv for storing

> a pointer to the per-cpu counters. This allows us to use core

> functionality for statistics handling.

>

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

> ---


Tested-by: Vladimir Oltean <olteanv@gmail.com>
Saeed Mahameed Nov. 2, 2020, 10:36 p.m. UTC | #4
On Sun, 2020-11-01 at 13:33 +0100, Heiner Kallweit wrote:
> It's a frequent pattern to use netdev->stats for the less frequently

> accessed counters and per-cpu counters for the frequently accessed

> counters (rx/tx bytes/packets). Add a default ndo_get_stats64()

> implementation for this use case. Subsequently switch more drivers

> to use this pattern.

> 

> Heiner Kallweit (5):

>   net: core: add dev_get_tstats64 as a ndo_get_stats64 implementation

>   net: make ip_tunnel_get_stats64 an alias for dev_get_tstats64

>   ip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback

>   net: dsa: use net core stats64 handling

>   tun: switch to net core provided statistics counters

> 


not many left,

$ git grep dev_fetch_sw_netstats drivers/

drivers/infiniband/hw/hfi1/ipoib_main.c:        dev_fetch_sw_netstats(s
torage, priv->netstats);
drivers/net/macsec.c:   dev_fetch_sw_netstats(s, dev->tstats);
drivers/net/usb/qmi_wwan.c:     dev_fetch_sw_netstats(stats, priv-
>stats64);

drivers/net/usb/usbnet.c:       dev_fetch_sw_netstats(stats, dev-
>stats64);

drivers/net/wireless/quantenna/qtnfmac/core.c:  dev_fetch_sw_netstats(s
tats, vif->stats64);

Why not convert them as well ?
macsec has a different implementation, but all others can be converted.
Heiner Kallweit Nov. 3, 2020, 2:46 p.m. UTC | #5
On 02.11.2020 23:36, Saeed Mahameed wrote:
> On Sun, 2020-11-01 at 13:33 +0100, Heiner Kallweit wrote:

>> It's a frequent pattern to use netdev->stats for the less frequently

>> accessed counters and per-cpu counters for the frequently accessed

>> counters (rx/tx bytes/packets). Add a default ndo_get_stats64()

>> implementation for this use case. Subsequently switch more drivers

>> to use this pattern.

>>

>> Heiner Kallweit (5):

>>   net: core: add dev_get_tstats64 as a ndo_get_stats64 implementation

>>   net: make ip_tunnel_get_stats64 an alias for dev_get_tstats64

>>   ip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback

>>   net: dsa: use net core stats64 handling

>>   tun: switch to net core provided statistics counters

>>

> 

> not many left,

> 

> $ git grep dev_fetch_sw_netstats drivers/

> 

> drivers/infiniband/hw/hfi1/ipoib_main.c:        dev_fetch_sw_netstats(s

> torage, priv->netstats);

> drivers/net/macsec.c:   dev_fetch_sw_netstats(s, dev->tstats);

> drivers/net/usb/qmi_wwan.c:     dev_fetch_sw_netstats(stats, priv-

>> stats64);

> drivers/net/usb/usbnet.c:       dev_fetch_sw_netstats(stats, dev-

>> stats64);

> drivers/net/wireless/quantenna/qtnfmac/core.c:  dev_fetch_sw_netstats(s

> tats, vif->stats64);

> 

> Why not convert them as well ?

> macsec has a different implementation, but all others can be converted.

> 

OK, I can do this. Then the series becomes somewhat bigger.
@Jakub: Would it be ok to apply the current series and I provide the
additionally requested migrations as follow-up series?
Jakub Kicinski Nov. 3, 2020, 5:05 p.m. UTC | #6
On Tue, 3 Nov 2020 15:46:27 +0100 Heiner Kallweit wrote:
> On 02.11.2020 23:36, Saeed Mahameed wrote:

> > On Sun, 2020-11-01 at 13:33 +0100, Heiner Kallweit wrote:  

> >> It's a frequent pattern to use netdev->stats for the less frequently

> >> accessed counters and per-cpu counters for the frequently accessed

> >> counters (rx/tx bytes/packets). Add a default ndo_get_stats64()

> >> implementation for this use case. Subsequently switch more drivers

> >> to use this pattern.

> >>

> >> Heiner Kallweit (5):

> >>   net: core: add dev_get_tstats64 as a ndo_get_stats64 implementation

> >>   net: make ip_tunnel_get_stats64 an alias for dev_get_tstats64

> >>   ip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback

> >>   net: dsa: use net core stats64 handling

> >>   tun: switch to net core provided statistics counters

> >>  

> > 

> > not many left,

> > 

> > $ git grep dev_fetch_sw_netstats drivers/

> > 

> > drivers/infiniband/hw/hfi1/ipoib_main.c:        dev_fetch_sw_netstats(s

> > torage, priv->netstats);

> > drivers/net/macsec.c:   dev_fetch_sw_netstats(s, dev->tstats);

> > drivers/net/usb/qmi_wwan.c:     dev_fetch_sw_netstats(stats, priv-  

> >> stats64);  

> > drivers/net/usb/usbnet.c:       dev_fetch_sw_netstats(stats, dev-  

> >> stats64);  

> > drivers/net/wireless/quantenna/qtnfmac/core.c:  dev_fetch_sw_netstats(s

> > tats, vif->stats64);

> > 

> > Why not convert them as well ?

> > macsec has a different implementation, but all others can be converted.

> >   

> OK, I can do this. Then the series becomes somewhat bigger.

> @Jakub: Would it be ok to apply the current series and I provide the

> additionally requested migrations as follow-up series?


Fine by me.