Data-Race Exceptions Have Benefits Beyond the Memory Model Benjamin P . Wood , Luis Ceze, Dan Grossman University of Washington 1
Why data-race exceptions? [Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...] 2
Why data-race exceptions? Find bugs. [Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...] 2
Why data-race exceptions? Find bugs. Simplify memory models. (DRF ⇒ SC) [Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...] 2
Why data-race exceptions? Find bugs. Simplify memory models. (DRF ⇒ SC) Avoid reasoning about memory reorderings. [Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...] 2
Why not data-race exceptions? 3
Why not data-race exceptions? Lock-free algorithms 3
Why not data-race exceptions? “Benign” races Lock-free algorithms 3
Why not data-race exceptions? “Benign” races Lock-free algorithms unchecked annotations 3
Why not data-race exceptions? “Benign” races Lock-free algorithms unchecked annotations Performance overheads ongoing research 3
Find bugs. Simplify memory models. Overheads costs benefits 4
Find bugs. Simplify memory models. Overheads costs benefits 4
Find bugs. Simplify memory models. Overheads costs benefits 4
? Find bugs. Simplify memory models. Overheads costs benefits This talk explores hidden benefits (and costs) of data-race exceptions in runtime systems . 4
? Find bugs. Simplify memory models. ? Overheads costs benefits This talk explores hidden benefits (and costs) of data-race exceptions in runtime systems . 4
? ? Overheads Find bugs. Simplify memory models. costs benefits This talk explores hidden benefits (and costs) of data-race exceptions in runtime systems . 5
All races are inherently wrong. 6
d e t a t o n n a n u All races are inherently wrong. ^ 6
d e t a t o n n a n u All races are inherently wrong. ^ d e t a t o n n a n u Exceptions ensure all races are impossible . ^ d e t a t o n n a n u Attempts at racy accesses ^ are exceptional, but legal . 6
Contributions contributions Review data races , exceptions, and sequential consistency. Properties of data-race exceptions enable conflict detection . Exploit data-race exceptions in concurrent garbage collection . Low-level data-race exceptions have subtle implications . Conclusions 7
Outline outline Review data races , exceptions, and sequential consistency. Properties of data-race exceptions enable conflict detection . Exploit data-race exceptions in concurrent garbage collection . Low-level data-race exceptions have subtle implications . Conclusions 8
data race a pair of concurrent , conflicting accesses Thread 1 Thread 2 x := 1 synchronization release(m) time r1 := y acquire(m) data race r2 := x y := 1 9
Thread 1 Thread 2 x := 1 synchronization release(m) time r1 := y acquire(m) data race r2 := x y := 1 exception on second access 10
data-race exceptions guarantee either data-race-free or exception Thread 1 Thread 2 x := 1 synchronization release(m) time r1 := y acquire(m) data race r2 := x y := 1 exception on second access 10
data-race exceptions guarantee either data-race-free or exception Thread 1 Thread 2 x := 1 synchronization release(m) time r1 := y acquire(m) data race r2 := x exception y := 1 exception on second access 10
Data-race exceptions Java/C++ DRF ⊕ exception and DRF ⇒ SC ⇓ SC or exception 11
data-race exceptions in HW precise Suspend the thread just before its racy access. Respect program order. acquire(m) ... race exception time r2 := x delivery y := 1 r3 := z handleable Deliver a trap with information about the race. 12
Concurrent Garbage Collection concurrent GC Concurrent mark-sweep: atomic/consistent heap traversal tri-color marking and write barriers Concurrent copying/moving: atomic object copying Piggyback on STM runtime [McGachey et al., PPoPP 2008] Lock-free algorithms [Pizlo et al., ISMM 2007, PLDI 2008] 13
mark-sweep GC thread Mutator Heap a gray( a ) next b c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 14
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next b c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 14
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next b c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 15
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 15
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 16
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next n .next := null next reachable, refs visited reachable, refs unvisited unreachable/unknown 16
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next n .next := null next gray( b .next) black( b ) reachable, refs visited reachable, refs unvisited unreachable/unknown 16
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next n .next := null next gray( b .next) black( b ) reachable, refs visited reachable, refs unvisited unreachable/unknown 17
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next next ✘ n .next := null gray( b .next) black( b ) reachable, refs visited reachable, refs unvisited unreachable/unknown collect( c ) 17
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next next ✘ n .next := null gray( b .next) black( b ) reachable, refs visited reachable, refs unvisited unreachable/unknown collect( c ) 17
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 18
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next reachable, refs visited reachable, refs unvisited unreachable/unknown 18
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next reachable, refs visited reachable, refs unvisited unreachable/unknown 19
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited unreachable/unknown 19
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited unreachable/unknown 20
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited gray( c .next) unreachable/unknown black( c ) 20
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited gray( c .next) unreachable/unknown black( c ) 21
mark-sweep GC thread Mutator Heap a gray( a ) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited gray( c .next) unreachable/unknown black( c ) 21
mark-sweep GC thread Mutator Heap a gray( a ) exception: gray(c) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited gray( c .next) unreachable/unknown black( c ) 21
mark-sweep GC thread Mutator Heap a gray( a ) exception: gray(c) gray( a .next) next black( a ) b n := a .next a .next := a .next.next c next gray( c ) next n .next := null gray( b .next) reachable, refs visited black( b ) reachable, refs unvisited exception: gray( c .next) unreachable/unknown ??? black( c ) 21
Recommend
More recommend