Subject: Re: [RFC net-next] net: mvneta: align xdp stats naming scheme to mlx5 driver

From: Jesper Dangaard Brouer <[email-masked]>
Date: Wed, 19 Feb 2020 09:26:11 +0100

On Tue, 18 Feb 2020 15:47:13 -0800 (PST)
David Miller <[email-masked]> wrote:

> From: Toke Høiland-Jørgensen <[email-masked]>
> Date: Tue, 18 Feb 2020 23:23:22 +0100
> 
> > Jakub Kicinski <[email-masked]> writes:
> >   
> >> On Tue, 18 Feb 2020 01:14:29 +0100 Lorenzo Bianconi wrote:  
> >>> Introduce "rx" prefix in the name scheme for xdp counters
> >>> on rx path.
> >>> Differentiate between XDP_TX and ndo_xdp_xmit counters
> >>> 
> >>> Signed-off-by: Lorenzo Bianconi <[email-masked]>  
> >>
> >> Sorry for coming in late.
> >>
> >> I thought the ability to attach a BPF program to a fexit of another BPF
> >> program will put an end to these unnecessary statistics. IOW I maintain
> >> my position that there should be no ethtool stats for XDP.
> >>
> >> As discussed before real life BPF progs will maintain their own stats
> >> at the granularity of their choosing, so we're just wasting datapath
> >> cycles.

Well, in practice we see that real-life[1] BPF progs don't maintain
stats (as I agree they _should_), and an end-user of this showed up on
XDP-newbies list, and I helped out, going in the complete wrong
direction, when it was simply the XDP prog dropping these packets, due
to builtin rate limiter.  It would have been so much easier to identify
via a simple counter, that I could have asked for from the sysadm.

[1] https://gitlab.com/Dreae/compressor/

> >>
> >> The previous argument that the BPF prog stats are out of admin control
> >> is no longer true with the fexit option (IIUC how that works).  
> > 
> > So you're proposing an admin that wants to keep track of XDP has to
> > (permantently?) attach an fexit program to every running XDP program and
> > use that to keep statistics? But presumably he'd first need to discover
> > that XDP is enabled; which the ethtool stats is a good hint for :)  
> 
> Really, mistakes happen and a poorly implemented or inserted fexit
> module should not be a reason to not have access to accurate and
> working statistics for fundamental events.

Yes, exactly.  These statistics counters are only "basic" XDP events,
that e.g. don't count the bytes.  They are only the first level of
identifying what the system is doing.  When digging deeper we need
tracepoint and fexit.

> I am therefore totally against requiring fexit for this functionality.
> If you want more sophisticated events or custome ones, sure, but not
> for this baseline stuff.

I fully agree.

> I do, however, think we need a way to turn off these counter bumps if
> the user wishes to do so for maximum performance.

I sort of agree, but having a mechanism to turn on/off these "basic"
counters might cost more than just always having them always on.  Even
the static_key infra will create sub-optimal code, which can throw-off
the advantage.

Maybe it is worth pointing out, that Lorenzo's code is doing something
smart, which lowers the overhead.  The stats struct (mvneta_stats) that
is passed to mvneta_run_xdp is not global, it only counts events in
this NAPI cycle, and is first transferred to the global counters when
drivers NAPI functions end, calling mvneta_update_stats().  (We can
optimized this a bit more on this HW as it is not necessary to have u64
long counters for these temp/non-global stats).

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer