On 26/11/2020 06:30, Krunal Bauskar wrote:
Improving spin-lock implementation on ARM.
------------------------------------------------------------

* Spin-Lock is known to have a significant effect on performance
   with increasing scalability.

* Existing Spin-Lock implementation for ARM is sub-optimal due to
   use of TAS (test and swap)

* TAS is implemented on ARM as load-store so even if the lock is not free,
   store operation will execute to replace the same value.
   This redundant operation (mainly store) is costly.

* CAS is implemented on ARM as load-check-store-check that means if the
   lock is not free, check operation, post-load will cause the loop to
   return there-by saving on costlier store operation. [1]

Can you add some code comments to explain that why CAS is cheaper than TAS on ARM?

Is there some official ARM documentation, like a programmer's reference manual or something like that, that would show a reference implementation of a spinlock on ARM? It would be good to refer to an authoritative source on this.

- Heikki


Reply via email to