split lock
背景
• 对⻬地址访问
cache line
cache coherence
https://en.wikipedia.org/wiki/Cache_coherence
场景
• 跨越两个 cache line 操作数据

• 原⼦操作(atomic operation)
问题
• 确保多个 cpu 间的数据⼀致性

• 两个 cache line 需要同时⽣效
处理⽅法 - intel
• 锁住整个内存总线(bus lock)
影响
• 阻碍其他 cpu 对内存的访问

• bus-locking 协议本身的开销,影响系统整体性能
例⼦
• 实时任务

• 云环境

• 安全
测试
• bus locking -> memory latency
⼯具
• sysbench

• lmbench

• perf bench

• mlc
sysbench
• 精度只到 ms 级别(sysbench —test=memory)
lmbench
• http://www.bitmover.com/lmbench/
• 不能单独测试主存
• https://github.com/intel/lmbench/blob/master/src/lat_mem_rd.c
mlc
• memory latency checker (@Intel)

• https://software.intel.com/en-us/articles/intelr-memory-
latency-checker
Latency Numbers Every Programmer Should Know
代码
https://gitlab.s.upyun.com/snippets/273
统计
• perf stat -e cpu/event=0xf4,umask=0x10/ -a -I 1000

• 对应 PMU 事件:sq_misc.split_lock
Split lock

Split lock