VSync: Push-Button Verification and Optimization for Synchronization Primitives on Weak Memory Models (Technical Report)

Jonas Oberhauser, Rafael Lourenco de Lima Chehab, Diogo Behrens, Ming Fu, Antonio Paolillo, Lilith Oberhauser, Koustubha Bhat, Yuzhong Wen, Haibo Chen, Jaeho Kim, Viktor VafeiadisarXiv 2021

Introduction

Modern multi-core systems rely on low-level synchronization primitives—such as spinlocks and MCS locks—to manage concurrent access to shared resources. However, implementing these primitives correctly and efficiently is notoriously difficult due to Weak Memory Models (WMMs) found in architectures like ARM and PowerPC. In these environments, memory operations can be reordered for performance, necessitating the precise placement of memory barriers (e.g., acquire and release). This report introduces VSync, a tool designed to automate the verification and optimization of these critical components.

The Challenge: Heisenbugs and Infinite State Spaces

Developers face a delicate balancing act: missing a barrier leads to "heisenbugs"—subtle, non-deterministic crashes—while over-synchronization degrades performance. Traditional Stateless Model Checkers (SMCs) often fail when analyzing synchronization primitives because they contain while loops that "await" memory changes. These spin-loops can create an infinite state space, causing tools to time out or requiring manual, error-prone code unrolling by the user.

Mapping a lock-acquire loop to an execution graph under weak memory models.

Await Model Checking (AMC)

VSync overcomes these limitations through Await Model Checking (AMC), built on top of the GenMC tool. AMC is governed by two core principles:

  1. Wasteful Execution Filtering: The tool identifies and discards executions where a spin-loop reads the same value repeatedly without change. By focusing only on iterations where the memory state evolves, the state space becomes finite and searchable.
  2. Bounded-Effect Principle: AMC assumes that failed iterations of an await loop (those that continue spinning) do not affect the rest of the system's state. This allows the tool to prune these iterations while still identifying safety violations.
The Await Model Checking (AMC) algorithm flowchart, highlighting the detection of Await Termination (AT) violations.

Beyond verification, VSync enables push-button optimization. A developer can provide a "correct but slow" implementation with heavy barriers, and VSync will automatically search for the most relaxed configuration that maintains safety and termination checks.

Evaluation and Real-World Impact

VSync was evaluated against high-profile targets, including the Linux kernel's qspinlock, the DPDK library, and internal Huawei products.

  • Automating Expertise: In a standout result, VSync optimized the Linux qspinlock in just 11 minutes, matching the configuration arrived at by top kernel experts over five years of manual tuning (from Linux 4.4 to 5.6).
  • Bug Discovery: The tool identified a missing release barrier in the DPDK MCS lock that could lead to deadlocks on ARM, as well as a missing acquire barrier in a production Huawei product that caused data corruption.
  • Performance Gains: Microbenchmarks on ARMv8 (Huawei TaiShan 200) and x86_64 platforms demonstrated that VSync-optimized locks significantly outperform sequentially consistent versions, particularly in low-contention scenarios where barrier overhead is most visible.

Conclusion

VSync represents a significant advancement in formal verification for concurrent systems. By effectively handling the "await" loops common in synchronization primitives, it moves verification from a manual "black art" to an automated, push-button process. Future work includes extending support to more complex memory models like the Linux Kernel Memory Model (LKMM) and handling variable-sized memory accesses.

Summary updated

BibTeX
@misc{oberhauser2021vsync,
  author = {Jonas Oberhauser and Rafael Lourenco de Lima Chehab and Diogo Behrens and Ming Fu and Antonio Paolillo and Lilith Oberhauser and Koustubha Bhat and Yuzhong Wen and Haibo Chen and Jaeho Kim and Viktor Vafeiadis},
  title = {{VSync: Push-Button Verification and Optimization for Synchronization Primitives on Weak Memory Models (Technical Report)}},
  year = {2021},
  eprint = {2102.06590},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.06590},
}
Figure