mbox series

[net-next,0/4] net: Convert some UDP tunnel drivers to NETDEV_PCPU_STAT_DSTATS.

Message ID cover.1733175419.git.gnault@redhat.com (mailing list archive)
Headers show
Series net: Convert some UDP tunnel drivers to NETDEV_PCPU_STAT_DSTATS. | expand

Message

Guillaume Nault Dec. 2, 2024, 9:48 p.m. UTC
VXLAN, Geneve and Bareudp use various device counters for managing
RX and TX statistics:

  * VXLAN uses the device core_stats for RX and TX drops, tstats for
    regular RX/TX counters and DEV_STATS_INC() for various types of
    RX/TX errors.

  * Geneve uses tstats for regular RX/TX counters and DEV_STATS_INC()
    for everything else, include RX/TX drops.

  * Bareudp, was recently converted to follow VXLAN behaviour, that is,
    device core_stats for RX and TX drops, tstats for regular RX/TX
    counters and DEV_STATS_INC() for other counter types.

Let's consolidate statistics management around the dstats counters
instead. This avoids using core_stats in VXLAN and Bareudp, as
core_stats is supposed to be used by core networking code only (and not
in drivers).  This also allows Geneve to avoid using atomic increments
when updating RX and TX drop counters, as dstats is per-cpu. Finally,
this also simplifies the code as all three modules now handle stats in
the same way and with only two different sets of counters (the per-cpu
dstats and the atomic DEV_STATS_INC()).

Patch 1 creates dstats helper functions that can be used outside of VRF
(before that, dstats was VRF-specific).
Patches 2 to 4 convert VXLAN, Geneve and Bareudp, one by one.

Guillaume Nault (4):
  vrf: Make pcpu_dstats update functions available to other modules.
  vxlan: Handle stats using NETDEV_PCPU_STAT_DSTATS.
  geneve: Handle stats using NETDEV_PCPU_STAT_DSTATS.
  bareudp: Handle stats using NETDEV_PCPU_STAT_DSTATS.

 drivers/net/bareudp.c          | 16 ++++++------
 drivers/net/geneve.c           | 12 ++++-----
 drivers/net/vrf.c              | 46 +++++++++-------------------------
 drivers/net/vxlan/vxlan_core.c | 28 ++++++++++-----------
 include/linux/netdevice.h      | 40 +++++++++++++++++++++++++++++
 5 files changed, 80 insertions(+), 62 deletions(-)

Comments

James Chapman Dec. 3, 2024, 8:12 a.m. UTC | #1
Hi Guillaume,

I can work on similar changes to l2tp if you haven't already started 
work on it.

James

On 02/12/2024 21:48, Guillaume Nault wrote:
> VXLAN, Geneve and Bareudp use various device counters for managing
> RX and TX statistics:
> 
>    * VXLAN uses the device core_stats for RX and TX drops, tstats for
>      regular RX/TX counters and DEV_STATS_INC() for various types of
>      RX/TX errors.
> 
>    * Geneve uses tstats for regular RX/TX counters and DEV_STATS_INC()
>      for everything else, include RX/TX drops.
> 
>    * Bareudp, was recently converted to follow VXLAN behaviour, that is,
>      device core_stats for RX and TX drops, tstats for regular RX/TX
>      counters and DEV_STATS_INC() for other counter types.
> 
> Let's consolidate statistics management around the dstats counters
> instead. This avoids using core_stats in VXLAN and Bareudp, as
> core_stats is supposed to be used by core networking code only (and not
> in drivers).  This also allows Geneve to avoid using atomic increments
> when updating RX and TX drop counters, as dstats is per-cpu. Finally,
> this also simplifies the code as all three modules now handle stats in
> the same way and with only two different sets of counters (the per-cpu
> dstats and the atomic DEV_STATS_INC()).
> 
> Patch 1 creates dstats helper functions that can be used outside of VRF
> (before that, dstats was VRF-specific).
> Patches 2 to 4 convert VXLAN, Geneve and Bareudp, one by one.
> 
> Guillaume Nault (4):
>    vrf: Make pcpu_dstats update functions available to other modules.
>    vxlan: Handle stats using NETDEV_PCPU_STAT_DSTATS.
>    geneve: Handle stats using NETDEV_PCPU_STAT_DSTATS.
>    bareudp: Handle stats using NETDEV_PCPU_STAT_DSTATS.
> 
>   drivers/net/bareudp.c          | 16 ++++++------
>   drivers/net/geneve.c           | 12 ++++-----
>   drivers/net/vrf.c              | 46 +++++++++-------------------------
>   drivers/net/vxlan/vxlan_core.c | 28 ++++++++++-----------
>   include/linux/netdevice.h      | 40 +++++++++++++++++++++++++++++
>   5 files changed, 80 insertions(+), 62 deletions(-)
>
Guillaume Nault Dec. 3, 2024, 11:39 a.m. UTC | #2
On Tue, Dec 03, 2024 at 08:12:29AM +0000, James Chapman wrote:
> Hi Guillaume,
> 
> I can work on similar changes to l2tp if you haven't already started work on
> it.

I haven't, so yes, please do. You can Cc me when submitting the patch,
so that I can ack it in time.

> James
> 
> On 02/12/2024 21:48, Guillaume Nault wrote:
> > VXLAN, Geneve and Bareudp use various device counters for managing
> > RX and TX statistics:
> > 
> >    * VXLAN uses the device core_stats for RX and TX drops, tstats for
> >      regular RX/TX counters and DEV_STATS_INC() for various types of
> >      RX/TX errors.
> > 
> >    * Geneve uses tstats for regular RX/TX counters and DEV_STATS_INC()
> >      for everything else, include RX/TX drops.
> > 
> >    * Bareudp, was recently converted to follow VXLAN behaviour, that is,
> >      device core_stats for RX and TX drops, tstats for regular RX/TX
> >      counters and DEV_STATS_INC() for other counter types.
> > 
> > Let's consolidate statistics management around the dstats counters
> > instead. This avoids using core_stats in VXLAN and Bareudp, as
> > core_stats is supposed to be used by core networking code only (and not
> > in drivers).  This also allows Geneve to avoid using atomic increments
> > when updating RX and TX drop counters, as dstats is per-cpu. Finally,
> > this also simplifies the code as all three modules now handle stats in
> > the same way and with only two different sets of counters (the per-cpu
> > dstats and the atomic DEV_STATS_INC()).
> > 
> > Patch 1 creates dstats helper functions that can be used outside of VRF
> > (before that, dstats was VRF-specific).
> > Patches 2 to 4 convert VXLAN, Geneve and Bareudp, one by one.
> > 
> > Guillaume Nault (4):
> >    vrf: Make pcpu_dstats update functions available to other modules.
> >    vxlan: Handle stats using NETDEV_PCPU_STAT_DSTATS.
> >    geneve: Handle stats using NETDEV_PCPU_STAT_DSTATS.
> >    bareudp: Handle stats using NETDEV_PCPU_STAT_DSTATS.
> > 
> >   drivers/net/bareudp.c          | 16 ++++++------
> >   drivers/net/geneve.c           | 12 ++++-----
> >   drivers/net/vrf.c              | 46 +++++++++-------------------------
> >   drivers/net/vxlan/vxlan_core.c | 28 ++++++++++-----------
> >   include/linux/netdevice.h      | 40 +++++++++++++++++++++++++++++
> >   5 files changed, 80 insertions(+), 62 deletions(-)
> > 
> 
> -- 
> James Chapman
> Katalix Systems Ltd
> https://katalix.com
> Catalysts for your Embedded Linux software development
>