linux - 自旋锁真的需要 DMB 吗?

标签 linux synchronization locking arm memory-barriers

我正在使用双 Cortex-A9 系统并且我一直在尝试 准确理解为什么自旋锁函数需要使用 DMB。它似乎 只要合并存储缓冲区被刷新锁定值 应该在解锁核心的 L1 中结束,SCU 应该 使另一个内核的 L1 中的值无效或更新。 这足以保持一致性和安全锁定吗?和 STREX 无论如何都不会跳过合并存储缓冲区,这意味着我们不会 甚至需要冲洗?

DMB 似乎是一把钝锤,尤其是因为它 默认为系统域,这可能意味着一路写入 到主内存,这可能很昂贵。

锁中的 DMB 是否作为司机的解决方法? 正确使用 smp_mb?

我目前看到,基于性能计数器,大约 5% 我的系统周期在 DMB 引起的停顿中消失。

最佳答案

我发现这些文章可能会回答您的问题:

特别是:

You will note the Data Memory Barrier (DMB) instruction that is issued once the lock has been acquired. The DMB guarantees that all memory accesses before the memory barrier will be observed by all of the other CPUs in the system before all memory accesses made after the memory barrier. This makes more sense if you consider that once a lock has been acquired, a program will then access the data structure(s) locked by the lock. The DMB in the lock function above ensures that accesses to the locked data structure are observed after accesses to the lock.

关于linux - 自旋锁真的需要 DMB 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13148421/

相关文章:

c# - 线程在什么情况下可以同时进入一个锁(Monitor)区域不止一次?

c++ - 静态链接的 c++ 二进制文件是否可以在具有相同体系结构的每个系统上工作?

linux - 使用 wkhtmltoimage 和 wkhtmltopdf(Linux centos6 64 位,hostgator)生成带有自定义字体的图像和 PDF

ruby-on-rails - 选择哪个亚马逊机器镜像 - Ruby on Rails

java - Java 1.4 中 Lock.tryLock() 的替代方案

java - 并发访问对 HashSet 的影响

java - RecursiveTask 中的 Spring 托管 bean 是否有锁定

mysql - 如何使用golang ping远程mysql

c - 无需轮询的 Linux 同步

c++ - 编写一个可以用作静态但需要锁的 C++ 类