Re: [PATCH net-next 3/3] ppp: synchronize netstats updates
From: Andrew Lunn
Date: Wed Jun 25 2025 - 04:17:16 EST
On Wed, Jun 25, 2025 at 11:40:20AM +0800, Qingfang Deng wrote:
> The PPP receive path can now run concurrently across CPUs (after converting
> rlock to rwlock in an earlier patch). This may lead to data races on
> net_device->stats.
>
> Convert all stats updates in both transmit and receive paths to use the
> DEV_STATS_INC() macro, which updates stats atomically.
Do you have benchmark numbers for these changes? How big an
improvement does it makes?
https://elixir.bootlin.com/linux/v6.15.3/source/include/linux/netdevice.h#L5549
/* Note: Avoid these macros in fast path, prefer per-cpu or per-queue counters. */
#define DEV_STATS_INC(DEV, FIELD) atomic_long_inc(&(DEV)->stats.__##FIELD)
As far as i can see, you only use DEV_STATS_INC() in error paths. It
might be worth mentioning this. As the comment says, you don't want to
use it on the hot path.
Andrew
---
pw-bot: cr