Property-Driven Fence Insertion using Reorder Bounded Model Checking

Saurabh Joshi, Daniel KroeningFM 2014 · DOI

Abstract

Modern processor architectures provide weaker memory consistency guarantees than sequential consistency to optimize performance. These weaker guarantees allow programs to exhibit behaviors where instructions appear to execute out of program order. To maintain correctness, architectures provide memory barriers, or "fences," to enforce ordering. However, manual fence placement is error-prone: too few fences lead to concurrency bugs, while too many degrade performance. We propose a property-driven technique using Reorder Bounded Model Checking (ROBMC) to identify the minimal set of fence locations. By bounding the number of allowed instruction reorderings during analysis, our approach filters out "innocent" reorderings that do not affect program correctness. Experimental results demonstrate that our technique, implemented on top of CBMC, is faster and solves more benchmark instances than existing state-of-the-art approaches.

Introduction

In the realm of multicore processing, architectures like x86 TSO, ARM, and PowerPC achieve high performance by allowing instructions to be executed out of order. While efficient, this "weak memory consistency" introduces significant complexity for concurrent programming. A program that works perfectly under sequential consistency may fail on weak memory hardware due to unexpected instruction interleavings.

To mitigate this, developers use fences to restrict reordering. The challenge lies in finding the "Goldilocks" zone of fence placement. Automated tools designed to restore full sequential consistency often over-provision fences, leading to unnecessary performance overhead. Property-driven tools aim to insert only the fences required to satisfy specific assertions, but they often struggle with the state-space explosion caused by "innocent reorderings"—instruction swaps that occur in hardware but do not actually trigger property violations.

The ROBMC Approach

We introduce Reorder Bounded Model Checking (ROBMC), a novel technique that adds a new dimension to traditional Bounded Model Checking (BMC). While standard BMC typically bounds loop iterations or recursion depth, ROBMC introduces a bound ($k$) on the number of instruction reorderings allowed in a single execution trace.

Iterative Exploration and Early Termination

Our algorithm operates through an iterative process:

  1. Initialization: Start with a small reordering bound (e.g., $k=1$).
  2. Search: The model checker searches for a property violation within the current bound.
  3. Fence Insertion: If a violation is found, the tool identifies the "culprit" reordering and inserts a fence to prevent it.
  4. Refinement: The process repeats until no more violations are found at the current bound.

To ensure the program is safe for any number of reorderings, we developed ROBMC-Et (Early Termination). This optimization uses unsatisfiable (UNSAT) cores from the SAT solver. If the solver can prove that no violation exists regardless of the bound $k$, the tool terminates early, providing a formal guarantee of correctness without exhaustive exploration of all possible reordering combinations.

Experimental Evaluation

We implemented ROBMC within the CBMC framework and evaluated it against classic concurrent algorithms and data structures, including:

  • Mutual Exclusion Algorithms: Dekker, Peterson, Lamport, and Szymanski.
  • Work-Stealing Queues: ChaseLev and Cilk.
  • Scalability Benchmarks: Parameterized code fragments designed to test the impact of increasing "innocent" reorderings.

Key Findings

  • Efficiency: ROBMC-Et significantly outperformed traditional Trace Enumeration (TE) and Accelerated Fence Insertion (FI) methods. In many cases, ROBMC-Et finished in seconds on instances where previous tools timed out (600s).
  • Query Stability: For the Peterson algorithm on TSO, traditional methods experienced an exponential explosion in the number of model checker queries as program size increased. ROBMC maintained a nearly constant query count, effectively filtering the "noise" of innocent reorderings.
  • Minimalism: In all benchmarks, ROBMC successfully identified the same minimal set of fences as exhaustive methods but arrived at the solution much faster.

Conclusion and Future Work

ROBMC addresses a critical bottleneck in automated formal verification for weak memory models. By focusing the search on the simplest explanations for failures (low $k$ values), the tool avoids the exponential overhead associated with irrelevant instruction reorderings.

While the added cardinality constraints required to track reorderings introduce some per-query overhead, the massive reduction in the total number of queries makes ROBMC a superior choice for complex concurrent programs. Future research will explore non-linear strategies for increasing the bound $k$ to further enhance scalability on large-scale industrial codebases.

Summary updated

BibTeX
@inproceedings{joshi2014property,
  author = {Saurabh Joshi and Daniel Kroening},
  title = {{Property-Driven Fence Insertion using Reorder Bounded Model Checking}},
  booktitle = {FM},
  year = {2014},
  doi = {10.1007/978-3-319-19249-9\_19},
}
Figure