[PATCH] net: stmmac: protect statistics updates with a spinlock
Eric Dumazet
edumazet at google.com
Fri Jan 5 01:58:42 PST 2024
On Fri, Jan 5, 2024 at 10:16 AM Petr Tesarik <petr at tesarici.cz> wrote:
>
> Add a spinlock to fix race conditions while updating Tx/Rx statistics.
>
> As explained by a comment in <linux/u64_stats_sync.h>, write side of struct
> u64_stats_sync must ensure mutual exclusion, or one seqcount update could
> be lost on 32-bit platforms, thus blocking readers forever.
>
> Such lockups have been actually observed on 32-bit Arm after stmmac_xmit()
> on one core raced with stmmac_napi_poll_tx() on another core.
>
> Signed-off-by: Petr Tesarik <petr at tesarici.cz>
This is going to add more costs to 64bit platforms ?
It seems to me that the same syncp can be used from two different
threads : hard irq and napi poller...
At this point, I do not see why you keep linux/u64_stats_sync.h if you
decide to go for a spinlock...
Alternative would use atomic64_t fields for the ones where there is no
mutual exclusion.
RX : napi poll is definitely safe (protected by an atomic bit)
TX : each TX queue is also safe (protected by an atomic exclusion for
non LLTX drivers)
This leaves the fields updated from hardware interrupt context ?
More information about the linux-arm-kernel
mailing list