Developing concurrent software is challenging, especially if it has to run on modern architectures with Weak Memory Models (WMMs) such as ARMv8, Power, or RISC-V. For the sake of performance, WMMs allow hardware and compilers to aggressively reorder memory accesses. To guarantee correctness, developers have to carefully place memory barriers in the code to enforce ordering among critical memory operations. While WMM architectures are growing in popularity, identifying the necessary and sufficient barriers of complex synchronization primitives is notoriously difficult. Unfortunately, publications often consider barriers to be just implementation details and omit them. In this technical note, we report our efforts in verifying the correctness of the Compact NUMA-Aware (CNA) lock algorithm on WMMs. The CNA lock is of special interest because it has been proposed as a new slowpath for Linux qspinlock, the main spinlock in Linux. Besides determining a correct and efficient set of barriers for the original CNA algorithm on WMMs, we investigate the correctness of Linux qspinlock and the latest Linux CNA patch (v15) on the memory models LKMM, ARMv8, and Power. Surprisingly, we have found that Linux qspinlock and, consequently, Linux CNA are incorrect according to LKMM, but are still correct when compiled to ARMv8 or Power.
翻译:开发同时使用的软件具有挑战性,特别是如果它必须运行在现代结构中,使用诸如ARMv8、电力或RIRC-V等弱记忆模型(WMM)运行。为了性能,WMM公司允许硬件和编译者对内存访问进行激烈的重新订购。为了保证正确性,开发者必须谨慎地在代码中设置记忆障碍,以便在关键的记忆操作中执行命令。虽然WMM公司的结构越来越受欢迎,查明复杂同步原始技术的必要和足够障碍是众所周知的困难。不幸的是,出版物常常认为障碍是公正的执行细节,而忽略了这些障碍。在本技术说明中,我们报告了我们为核查NUMA-Awarard(CNA)合同锁算对WMM(CN)的正确性工作。CNA锁特别令人感兴趣,因为它被提议为Linux qspinlock(Linux qspinlock的主要螺旋锁)的新慢路。除了确定一套正确和有效的障碍之外,我们调查了LNA qspinlock和最新的Linux CNA(15)的正确性CNA(LMMMV)的准确性模型,我们发现了LMMU和LMU和R的R的R的R)的R。