verifying concurrent software using movers in cspec
play

Verifying concurrent software using movers in CSPEC Tej Chajed , - PowerPoint PPT Presentation

Verifying concurrent software using movers in CSPEC Tej Chajed , Frans Kaashoek, Butler Lampson*, Nickolai Zeldovich MIT CSAIL and *Microsoft Concurrent software is difficult to get right Programmer cannot reason about code in sequence 2


  1. Verifying concurrent software using movers in CSPEC Tej Chajed , Frans Kaashoek, Butler Lampson*, Nickolai Zeldovich MIT CSAIL and *Microsoft

  2. Concurrent software is difficult to get right Programmer cannot reason about code in sequence… � 2

  3. Concurrent software is difficult to get right Programmer cannot reason about code in sequence… instead, must consider many executions: � 3

  4. Concurrent software is difficult to get right Programmer cannot reason about code in sequence… instead, must consider many executions: … � 3

  5. Goal: verify concurrent software � 4

  6. Challenge for formal verification • Proofs must also cover every execution • Many approaches to managing this complexity • movers [Lipton, 1975] • rely-guarantee [1983] • RGSep [CONCUR 2007] • FCSL [PLDI 2015] • Iris [POPL 2017, LICS 2018, others] • many others � 5

  7. Challenge for formal verification • Proofs must also cover every execution • Many approaches to managing this complexity • movers [Lipton, 1975] • rely-guarantee [1983] • RGSep [CONCUR 2007] • FCSL [PLDI 2015] • Iris [POPL 2017, LICS 2018, others] • many others • This work: our experience using movers � 5

  8. Movers: reduce concurrent executions to sequential ones time 1 2 3 blue thread 1 A 2 3 B green thread A B � 6

  9. Movers: reduce concurrent executions to sequential ones 1 2 3 blue thread 1 A 2 3 B green thread A B movers has the same e ff ect as 1 2 3 A B � 6

  10. Movers: reduce concurrent executions to sequential ones 1 2 3 blue thread 1 A 2 3 B green thread A B movers has the same e ff ect as 1 2 3 A B sequential reasoning 2 1 3 A B � 6

  11. Prior systems with mover reasoning CIVL [CAV ’15, CAV ’18] framework relies pen & paper proofs IronFleet [SOSP ’15] only move network send/receive � 7

  12. Contribution: CSPEC • Framework for verifying concurrency in systems software • general-purpose movers • patterns to support mover reasoning • machine checked in Coq to support extensibility � 8

  13. Contribution: CSPEC • Framework for verifying concurrency in systems software • general-purpose movers • patterns to support mover reasoning • machine checked in Coq to support extensibility • Case studies using CSPEC • Lock-free file-system concurrency • Spinlock on top of x86-TSO (see paper) � 8

  14. Case study: mail server using file-system concurrency file system spool mbox � 9

  15. Mail servers exploit file-system concurrency # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 10

  16. Mail servers exploit file-system concurrency msg # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 11

  17. Spooling avoids reading partially-written messages $TID =10 # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 12

  18. Spooling avoids reading partially-written messages $TID =10 # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 10 while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 12

  19. Threads use unique IDs to avoid conflicts msg $TID =10 $TID =11 # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 13

  20. Threads use unique IDs to avoid conflicts $TID =10 $TID =11 # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 14

  21. Threads use unique IDs to avoid conflicts $TID =10 $TID =11 # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 11 while True: 1 2 3 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 14

  22. Timestamps help generate unique message names # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 11 while True: 1 2 3 4 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): link(/spool/11, /mbox/4) break # cleanup unlink (“/spool/$TID”) � 15

  23. Timestamps help generate unique message names # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 11 while True: 1 2 3 4 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): link(/spool/10, /mbox/4) break # cleanup EEXISTS ✗ unlink (“/spool/$TID”) � 16

  24. Timestamps help generate unique message names # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 11 while True: 1 2 3 4 5 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): link(/spool/10, /mbox/5) break # cleanup unlink (“/spool/$TID”) � 17

  25. Delivery concurrency does not use locks # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store 10 while True: 1 2 3 4 5 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 18

  26. Delivery concurrency does not use locks # accept def deliver(msg): file system # spool create (“/spool/$TID”) spool mbox write (“/spool/$TID”, msg) # store while True: 1 2 3 4 5 t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break # cleanup unlink (“/spool/$TID”) � 19

  27. Proving delivery correct in CSPEC delivery specification implementation and proof file-system spec CSPEC provides supporting definitions CSPEC and theorems � 20

  28. Proof engineer reasons about file-system operations def deliver(msg): create (“/spool/$TID”, msg) while True: t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break unlink (“/spool/$TID”) create( link( link( unlink( /sp/$TID, /sp/$TID, /sp/$TID, /sp/$TID) msg) /mbox/$t) /mbox/$t) ✓ ✓ ✓ EEXISTS ✗ � 21

  29. Proof engineer reasons about file-system operations collapsed to def deliver(msg): one operation create (“/spool/$TID”) create (“/spool/$TID”, msg) write (“/spool/$TID”, msg) while True: t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break unlink (“/spool/$TID”) create( link( link( unlink( /sp/$TID, /sp/$TID, /sp/$TID, /sp/$TID) msg) /mbox/$t) /mbox/$t) ✓ ✓ ✓ EEXISTS ✗ � 21

  30. Proof engineer reasons about interleaving of file- system operations def deliver(msg): create (“/spool/$TID”, msg) while True: t = time.time() if link (“/spool/$TID”, “/mbox/$t”): break unlink (“/spool/$TID”) create( link( link( unlink( /sp/$TID, /sp/$TID, /sp/$TID, /sp/$TID) create link unlink msg) /mbox/$t) /mbox/$t) ✓ ✓ ✓ ✓ EEXISTS ✗ We assume file-system operations are atomic � 22

  31. Proving atomicity of delivery atomicity : concurrent deliveries appear create create link link link unlink unlink to execute all at once (in some order) ✓ ✓ ✗ deliver deliver create link unlink create link link unlink ✓ ✓ ✗ � 23

  32. Proving atomicity of delivery atomicity : concurrent deliveries appear create create link link link unlink unlink to execute all at once (in some order) ✓ ✓ ✗ Step 1: developer identifies commit point deliver deliver create link unlink create link link unlink ✓ ✓ ✗ � 23

  33. Proving atomicity of delivery atomicity : concurrent deliveries appear create create link link link unlink unlink to execute all at once (in some order) ✓ ✓ ✗ Step 1: developer identifies commit point Step 2: prove operation occurs logically at commit point deliver deliver create link unlink create link link unlink ✓ ✓ ✗ � 23

  34. Example of movers for this execution create create link link link unlink unlink ✓ ✓ ✗ � 24

  35. Example of movers for this execution create create link link link unlink unlink ✓ ✓ ✗ create link create link link unlink unlink ✓ ✓ ✗ � 24

  36. Example of movers for this execution create create link link link unlink unlink ✓ ✓ ✗ create link create link link unlink unlink ✓ ✓ ✗ create link unlink create link link unlink ✓ ✓ ✗ � 24

  37. Right mover can be reordered after any green thread operation A A r r � 25

Recommend


More recommend