Atom-Aid: Detecting and Surviving Atomicity Violations Brandon Lucia, Joseph Devietti, Karin Strauss and Luis Ceze LBA Reading Group 7/3/08 Slides by Michelle Goodstein
Motivation Parallel programs are hard to write Non-deterministic bugs emerge Data races Deadlocks Atomicity Violations Non-deterministically affect program performance Large portion of non-deadlock concurrency bugs
Motivation Observe that BulkSC, ASO, Implicit Transactions provide implicit atomicity Implicit Atomicity: Two accesses in the same “chunk” appear atomic Leverage implicit atomicity to avoid atomicity violations
Outline Motivation Implicit Atomicity Atom-Aid Design Experimental Setup & Results Conclusions
Implicit Atomicity Property of systems that: Group instructions into larger chunks Support consistency at coarser granularity Coarse grain consistency Reduces space of possible interleavings Software remains oblivious Atom-Aid Works if system provides implicit atomicity Built on BulkSC
Atomicity Violation
Space of Interleavings
Serializability Serializable iff order assumed by the programmer produces same final state as actual interleaving
Serializability
Implicit Atomicity and Atomicity Violations Atomicity-lacking section Portion of code from one memory access to another which should be atomic but is not Intuitively: If all code for an atomicity violation lies within same “chunk”, violation will never occur Natural hiding
Implicit Atomicity and Atomicity Violations Formally c is the default chunk size d is the size of an atomicity-lacking section If c < d |Atomicity-lacking section| > |default chunk| Pr(hiding violation) = 0 If c ≥ d Pr(hiding violation) = (c-d+1)/c
Hiding an Atomicity Violation d atomicity lacking section Chunk bdry (c-d)th instr c 1 st memory operation from atomicity lacking section here, entire section atomic
Implications of natural hiding
Atomicity Violation Statistics Typical atomicity violation: instr If chunk size ~ 2,000 instrs Pr(hiding violation) around 63-75% “Naturally hiding” violations Goal: Raise Pr(hiding violation) ~ 100%
Atom-Aid Design Smart chunking Place chunk boundaries deliberately instead of arbitrarily Try to increase number of hidden atomicity violations Intuition Observe accesses to some location a Notice unserializable sequence of accesses to a Next time access a, (potentially) “do something” “Do something” : Add a chunk boundary
Atom-Aid Design Details Track: Type and address of memory op Read/Write Sets R C, W C : current chunk R P, W P : previous chunk R RC, W RC : remote ops while current chunk executing R RP, W RP : remote ops while prior chunk executing ChunkBreakSet Addresses with past unserializable accesses
Atom-Aid Design Details
Address A is Added to ChunkBreakSet Another access to A: Atom-Aid is alerted Decides whether to break a chunk prematurely Always breaking a chunk doesn’t help Maintain two conditions Never break a chunk twice If add address to ChunkBreakSet during a chunk, cannot break that chunk
Chunk Breaking Flowchart
Atom-Aid Implementation Built on BulkSC Three sets of signatures added R C, W C : part of BulkSC R P, W P : copy from R C, W C after commit R RC, W RC : remote downgrades, copy from other processors sigs R RP, W RP : copy from R CP,W CP after commit ChunkBreakSet: Signature, or cache augmentation
Experimental Setup Model BulkSC like system using PIN Results average over several runs 95% confidence intervals added around average Explicitly annotate code Begin/end of atomicity-lacking section Dynamically check if markers within same chunk Yes: atomicity violation hidden
Observations None of the “natural” violations exceeded 1000 instructions BankAccount2, CircularList2, LogProc&Sweep2 modified to evaluate larger sizes
Workloads
Natural Hiding (no Atom-Aid)
Atom-Aid: Bug Kernels
Atom-Aid: Applications
Atom-Aid: Signature vs Exact
Atom-Aid as a debugger Record the PC when Atom-Aid inserts a chunk boundary Group PCs into line of code, function where it appears Examine functions in order of highest lowest frequency to look for bugs
Time to find bugs
Conclusions Implicit atomicity can help programmers by preventing bugs from becoming visible Atom-Aid leverages implicit atomicity via smart chunk boundaries Atom-Aid can hide almost 100% of atomicity violations