The magic is probably in here https://github.com/torvalds/linux/blob/master/arch/arm64/include/asm/atomic.h Note sure why the counter is required though.