data race exceptions have benefits beyond the memory model
play

Data-Race Exceptions Have Benefits Beyond the Memory Model Benjamin - PowerPoint PPT Presentation

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;


  1. Data-Race Exceptions Have Benefits Beyond the Memory Model Benjamin P . Wood , Luis Ceze, Dan Grossman University of Washington 1

  2. 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

  3. 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

  4. 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

  5. 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

  6. Why not data-race exceptions? 3

  7. Why not data-race exceptions? Lock-free algorithms 3

  8. Why not data-race exceptions? “Benign” races Lock-free algorithms 3

  9. Why not data-race exceptions? “Benign” races Lock-free algorithms unchecked annotations 3

  10. Why not data-race exceptions? “Benign” races Lock-free algorithms unchecked annotations Performance overheads ongoing research 3

  11. Find bugs. Simplify memory models. Overheads costs benefits 4

  12. Find bugs. Simplify memory models. Overheads costs benefits 4

  13. Find bugs. Simplify memory models. Overheads costs benefits 4

  14. ? Find bugs. Simplify memory models. Overheads costs benefits This talk explores hidden benefits (and costs) of data-race exceptions in runtime systems . 4

  15. ? Find bugs. Simplify memory models. ? Overheads costs benefits This talk explores hidden benefits (and costs) of data-race exceptions in runtime systems . 4

  16. ? ? Overheads Find bugs. Simplify memory models. costs benefits This talk explores hidden benefits (and costs) of data-race exceptions in runtime systems . 5

  17. All races are inherently wrong. 6

  18. d e t a t o n n a n u All races are inherently wrong. ^ 6

  19. 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

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. 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

  26. Data-race exceptions Java/C++ DRF ⊕ exception and DRF ⇒ SC ⇓ SC or exception 11

  27. 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

  28. 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

  29. mark-sweep GC thread Mutator Heap a gray( a ) next b c next next reachable, refs visited reachable, refs unvisited unreachable/unknown 14

  30. 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

  31. 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

  32. 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

  33. 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

  34. 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

  35. 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

  36. 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

  37. 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

  38. 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

  39. 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

  40. 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

  41. 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

  42. 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

  43. 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

  44. 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

  45. 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

  46. 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

  47. 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

  48. 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