The Linux kernel has a family of barrier functions suitable for communicating across processors (smp_*), with DMA devices (dma_*), and for other uses (mb/rmb/wmb).
I've often found it useful to know what hardware instructions a particular barrier maps to; this table maps each Linux barrier to its corresponding implementation on x86-64 and aarch64.
x86_64 | aarch64 | |
smp_rmb | __asm__ __volatile__("": : :"memory") [1] | dmb ishld [1] |
smp_wmb | __asm__ __volatile__("": : :"memory") [1] | dmb ishst [1] |
smp_mb | asm volatile("lock; addl $0,-4(%%rsp)" ::: "memory", "cc") [1] | dmb ish [1] |
dma_rmb | __asm__ __volatile__("": : :"memory") [1] | dmb oshld [1] |
dma_wmb | __asm__ __volatile__("": : :"memory") [1] | dmb oshst [1] |
mb | mfence [1] | dsb sy [1] |
rmb | lfence [1] | dsb ld [1] |
wmb | sfence [1] | dsb st [1] |