Subject: Re: [PATCH net-next] net: dlink: add synchronization for stats update

From: Jakub Kicinski <[email-masked]>
Date: Wed, 23 Apr 2025 18:42:35 -0700

On Tue, 22 Apr 2025 04:16:44 +0900 Moon Yeounsu wrote:
> -	dev->stats.tx_errors++;
> +	np->tx_errors++;
>  	/* Ttransmit Underrun */
>  	if (tx_status & 0x10) {
>  		dev->stats.tx_fifo_errors++;
> @@ -904,7 +904,7 @@ tx_error (struct net_device *dev, int tx_status)
>  	}
>  	/* Maximum Collisions */
>  	if (tx_status & 0x08)
> -		dev->stats.collisions++;
> +		np->collisions++;

These can be updated concurrently with the reading.
Since they are 64b on 32b machines the update may not be atomic.
So to be safe please take the spin lock around the increments,
or you could convert them to a atomic_t, or you can make them 32 bits
and update them with WRITE_ONCE() read with READ_ONCE()..
-- 
pw-bot: cr