> 6.1. Accounting spinlocks: > > Spinlocks are supposed to be fast, especially for the case that they are not > contested, but in such critical paths their impact shouldn't be neglected. > > SPI_STATISTICS_ADD_TO_FIELD: This macro defined in spi.h has a spinlock, and > it is used 4 times directly in __spi_sync(). It is also used in > spi_transfer_one_message() which is called from there. Removing the spinlocks > (thus introducing races) makes the code measurably faster (several us). > > spi_statistics_add_transfer_stats(): Called twice from > spi_transfer_one_message(), and also contains a spinlock. Removing these again > has a measurable impact of several us. Maybe something from the network stack can be learnt here: https://www.kernel.org/doc/html/latest/locking/seqlock.html https://elixir.bootlin.com/linux/v5.18-rc6/source/include/linux/u64_stats_sync.h Andrew