Re: [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and drops per ring

From: Sebastian Andrzej Siewior

Date: Mon Oct 19 2026 - 17:54:55 EST


On 2026-10-19 09:04:38 [-0400], Daniel Zahka wrote:
> >> An RCU approach is used because ndo_get_stats64 is not called with the
> >> instance lock.
> >
> > 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).

> 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.
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.

> >> Signed-off-by: Daniel Zahka <daniel.zahka@xxxxxxxxx>

Sebastian