mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Daniel Zahka <daniel.zahka@gmail.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	kernel-team@meta.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Eric Dumazet <edumazet@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and drops per ring
Date: Tue, 20 Oct 2026 23:21:55 +0200	[thread overview]
Message-ID: <20261020212155.47v0ot4g@linutronix.de> (raw)
In-Reply-To: <20261019190543.419e70bc@kernel.org>

On 2026-10-19 19:05:43 [-0700], Jakub Kicinski wrote:
> On Mon, 19 Oct 2026 23:54:05 +0200 Sebastian Andrzej Siewior wrote:
> > On 2026-10-19 09:04:38 [-0400], Daniel Zahka wrote:
> > > > Why do you have the two mpnic_base_stats and fold the stats into into
> > > > it? My guess would be that on stop the counters are reset and you want
> > > > to preserve the stats.
> > > >  
> > > 
> > > Not sure I understand. I think you are asking about two things:
> > > 
> > > 1. Why have two mpnic_base_stats?
> > > 
> > > To avoid a separate heap allocation that can fail. Handling an
> > > allocation failure in the ndo_stop path when doing the aggregation into
> > > the base stats is tricky.  
> > 
> > Right. But looking at hinic3_get_stats64() for instance (I just grabbed
> > a random one) it simply does query the stats for each queue, add up,
> > return. It probably does not drop the queues on down, just reallocates
> > them while changing the number of queues (and maybe MTU).
> 
> I don't think pre-allocating stats for chips which supports thousands
> of queues is reasonable.

I don't mean to pre-allocate stats. If device-down removes queues then
the stats gone, so what. The queues could remain.

> > > 2. Why split stats into base stats and per queue stats, and why reset
> > > the per queue counts when the device transitions down?
> > > 
> > > This is the way the stats in netdev.yaml are exposed depending on the
> > > 'scope' request attribute. My reading of the relevant kernel docs is
> > > that the per queue counters are counting events for the current live
> > > queue, so it makes sense to reset them and fold those counts into the
> > > base stats when the interface is transitioned down.  
> > 
> > Is there any other driver doing this?
> > There is ::get_sset_count() and so on for the per-queue stats.
> 
> You may be mixing up queue stats (netlink) with the old ethtool -S
> kitchen sink / garbage dump.

The statistics is folded on device-down into a global counter. So on
device-up the statistics is still available. At least that is my
understanding. This means the per-queue stats are lost and global stats
don't match the per queue stats anymore.

> > If the interface goes down and frees all its queues, then the stats are
> > gone, true. But preserving them at the price of two (down+up) forced RCU
> > grace period, I don't know. It looks like a bit too much.
> 
> This is a modern driver, the down / up path is not taken when interface
> is reconfigured. It's only taken when the interface is actually taken
> down or bought up. Which virtually never happens for a datacenter NIC.

So if this never happens, it might not be needed to preserve this. That
force-RCU might not be needed. This does happen on down and I would
assume that the device is no longer processing packets.

> I don't mean to dismiss your concerns, we agonized over this off-list
> for a week, and don't love the resulting flow, either. But I strongly
> prefer the RCU grace period that never really runs, but is easy to
> reason about, to more advanced fixes which use memory barriers etc.

Right. If you think is all makes sense and is needed then why not. It
just looks odd.

> Anyway, I'll punt to Paolo for the final call but I think this is fine.
> 
> Acked-by: Jakub Kicinski <kuba@kernel.org>

Sebastian

  reply	other threads:[~2026-10-20 21:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 12:04 [PATCH net-next v2 0/4] eth: mpnic: add basic netdev statistics Daniel Zahka
2026-10-12 12:04 ` [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and drops per ring Daniel Zahka
2026-10-13 12:05   ` netdev-bot+sashiko
2026-10-13 12:10     ` Daniel Zahka
2026-10-16 22:09   ` Sebastian Andrzej Siewior
2026-10-19 13:04     ` Daniel Zahka
2026-10-19 21:54       ` Sebastian Andrzej Siewior
2026-10-20  2:05         ` Jakub Kicinski
2026-10-20 21:21           ` Sebastian Andrzej Siewior [this message]
2026-10-20 21:34             ` Daniel Zahka
2026-10-20 21:50             ` Jakub Kicinski
2026-10-12 12:04 ` [PATCH net-next v2 2/4] eth: mpnic: report per-queue stats Daniel Zahka
2026-10-13 12:05   ` netdev-bot+sashiko
2026-10-13 13:30     ` Daniel Zahka
2026-10-20  2:00       ` Jakub Kicinski
2026-10-12 12:04 ` [PATCH net-next v2 3/4] eth: mpnic: count Tx queue stops and wakes Daniel Zahka
2026-10-12 12:04 ` [PATCH net-next v2 4/4] eth: mpnic: count Rx allocation failures Daniel Zahka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261020212155.47v0ot4g@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=alexanderduyck@fb.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.zahka@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®