Hongjin Liang and Xinyu Feng

Slides:



Advertisements
Similar presentations
1 Lecture 5 Towards a Verifying Compiler: Multithreading Wolfram Schulte Microsoft Research Formal Methods 2006 Race Conditions, Locks, Deadlocks, Invariants,
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Bounded Model Checking of Concurrent Data Types on Relaxed Memory Models: A Case Study Sebastian Burckhardt Rajeev Alur Milo M. K. Martin Department of.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Partially Disjunctive Shape Analysis Josh Berdine Byron Cook MSR Cambridge Tal Lev-Ami Roman Manevich Mooly Sagiv Ran Shaham Tel Aviv University Ganesan.
Software Transactional Objects Guy Eddon Maurice Herlihy TRAMP 2007.
The many faces of TM Tim Harris. Granularity Distributed, large-scale atomic actions Composable shared memory data structures Leaf shared memory data.
Time-based Transactional Memory with Scalable Time Bases Torvald Riegel, Christof Fetzer, Pascal Felber Presented By: Michael Gendelman.
Shape Analysis for Fine-Grained Concurrency using Thread Quantification Josh Berdine Microsoft Research Joint work with: Tal Lev-Ami, Roman Manevich, Mooly.
Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems Håkan Sundell Philippas Tsigas.
Wait-Free Linked-Lists Shahar Timnat, Anastasia Braginsky, Alex Kogan, Erez Petrank Technion, Israel Presented by Shahar Timnat 469-+
IBM T. J. Watson Research Center Conditions for Strong Synchronization Maged Michael IBM T J Watson Research Center Joint work with: Martin Vechev, Hagit.
Wait-Free Queues with Multiple Enqueuers and Dequeuers
QED: A Simplifier for Concurrent Programs Shaz Qadeer Microsoft Research Joint work with Tayfun ElmasAli SezginSerdar Tasiran.
Concurrent programming for dummies (and smart people too) Tim Harris & Keir Fraser.
Techniques for proving programs with pointers A. Tikhomirov.
Refinement Verification of Concurrent Programs and Its Applications Hongjin Liang Univ. of Science and Technology of China Advisors: Xinyu Feng and Zhong.
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A AAA A A A AA A Proving that non-blocking algorithms don't block.
Addressing the Challenges of Current Software. Questions to Address Why? What? Where? How?
Architecture-aware Analysis of Concurrent Software Rajeev Alur University of Pennsylvania Amir Pnueli Memorial Symposium New York University, May 2010.
Heap Decomposition for Concurrent Shape Analysis R. Manevich T. Lev-Ami M. Sagiv Tel Aviv University G. Ramalingam MSR India J. Berdine MSR Cambridge Dagstuhl.
Reduction, abstraction, and atomicity: How much can we prove about concurrent programs using them? Serdar Tasiran Koç University Istanbul, Turkey Tayfun.
“FENDER” AUTOMATIC MEMORY FENCE INFERENCE Presented by Michael Kuperstein, Technion Joint work with Martin Vechev and Eran Yahav, IBM Research 1.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
A Rely-Guarantee-Based Simulation for Verifying Concurrent Program Transformations Hongjin Liang, Xinyu Feng & Ming Fu Univ. of Science and Technology.
A simple sequential reasoning approach for sound modular verification of mainstream multithreaded programs Wolfram Schulte & Bart Jacobs Microsoft Research.
Scalable and Lock-Free Concurrent Dictionaries
Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.
Verifying Commit-Atomicity Using Model Checking Cormac Flanagan University of California, Santa Cruz.
Comparison Under Abstraction for Verifying Linearizability Daphna Amit Noam Rinetzky Mooly Sagiv Tom RepsEran Yahav Tel Aviv UniversityUniversity of Wisconsin.
SUPPORTING LOCK-FREE COMPOSITION OF CONCURRENT DATA OBJECTS Daniel Cederman and Philippas Tsigas.
An example demonstrating the ABA problem Xinyu Feng University of Science and Technology of China.
Compositional Verification of Termination-Preserving Refinement of Concurrent Programs Hongjin Liang Univ. of Science and Technology of China (USTC) Joint.
Thread Quantification for Concurrent Shape Analysis Josh BerdineMSR Cambridge Tal Lev-AmiTel Aviv University Roman ManevichTel Aviv University Mooly Sagiv.
Verifying Concurrent Objects under Fair Scheduling Hongjin Liang University of Science and Technology of China (USTC) Joint work with Xinyu Feng.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Testing and Verifying Atomicity of Composed Concurrent Operations Ohad Shacham Tel Aviv University Nathan Bronson Stanford University Alex Aiken Stanford.
VMCAI / POPL 2009 Spy Report. Topics of Interest (I) Semantics of concurrent programs – Programming languages & abstractions – Transactional memory (TM)
Concurrency Verification. Why concurrency verification Concurrent programs show in many systems –Multi-task support in OS kernels –Handling interrupts.
Characterizing Progress Properties of Concurrent Objects via Contextual Refinements Hongjin Liang Univ. of Science and Technology of China (USTC) Joint.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
A Consistency Framework for Iteration Operations in Concurrent Data Structures Yiannis Nikolakopoulos A. Gidenstam M. Papatriantafilou P. Tsigas Distributed.
Challenges in Non-Blocking Synchronization Håkan Sundell, Ph.D. Guest seminar at Department of Computer Science, University of Tromsö, Norway, 8 Dec 2005.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
Eran Yahav 1. Previously…  An algorithmic view  Abstract data types (ADT)  Correctness Conditions  Sequential consistency  Linearizability  Treiber’s.
Model Checking Linearizability via Refinement 1 ICFEM 2008 Model Checking Linearizability via Refinement Yang LIU, Wei CHEN, Yanhong A. LIU, and Jun SUN.
CS510 Concurrent Systems Jonathan Walpole. A Methodology for Implementing Highly Concurrent Data Objects.
A Program Logic for Concurrent Objects under Fair Scheduling Hongjin Liang and Xinyu Feng University of Science and Technology of China (USTC) To appear.
Program Logic for Concurrency Refinement Verification Xinyu Feng University of Science and Technology of China Joint work with Hongjin Liang (USTC) and.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
1 1 Nastaran Shafiei VERIFICATION OF A NON-BLOCKING ARRAY-BASED QUEUE ALGORITHM.
A Calculus of Atomic Actions Tayfun Elmas, Shaz Qadeer and Serdar Tasiran POPL ‘ – Seminar in Distributed Algorithms Cynthia Disenfeld 27/05/2013.
An algorithm of Lock-free extensible hash table Yi Feng.
Scalable lock-free Stack Algorithm Wael Yehia York University February 8, 2010.
Distributed Algorithms (22903) Lecturer: Danny Hendler Lock-free stack algorithms.
Simplifying Linearizability Proofs Using Reduction and Abstraction Serdar Tasiran Koc University, Istanbul, Turkey Tayfun Elmas, Ali Sezgin, Omer Subasi.
A Calculus of Atomic Actions Serdar Tasiran Koc University, Istanbul, Turkey Tayfun ElmasShaz Qadeer Koc University Microsoft Research.
A Program Logic for Concurrent Objects under Fair Scheduling Hongjin Liang and Xinyu Feng University of Science and Technology of China (USTC)
Concurrency 2 CS 2110 – Spring 2016.
Håkan Sundell Philippas Tsigas
Joint work with Yong Li, Xinyu Feng, Zhong Shao and Yu Zhang
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Hongjin Liang, Xinyu Feng & Ming Fu
Distributed Algorithms (22903)
Progress of Concurrent Objects with Partial Methods
Scalable lock-free Stack Algorithm
Multicore programming
Presentation transcript:

Modular Verification of Linearizability with Non-Fixed Linearization Points Hongjin Liang and Xinyu Feng Univ. of Science and Technology of China (USTC)

This talk: correctness of concurrent objects Modern languages provide concurrent objects (libraries) to help program for multicore systems. void push(int v) { … } int pop() { … push(7); x = pop(); … push(6); Concurrent objects Client code java.util.concurrent This talk: correctness of concurrent objects

Example: Treiber’s Non-Blocking Stack Top v1 next vk next … How to specify/prove correctness? t next v x 4 while(!b){ 5 t := Top; 6 x.next := t; 7 b := cas(&Top, t, x); 8 } push(int v): 1 local b:=false, x, t; 2 x := new Node(); 3 x.data := v;

Linearizability Standard correctness criterion for objects O [Herlihy & Wing’90] Standard correctness criterion for objects O All concurrent executions of O are “equivalent” to some sequential ones

Linearization point (LP) Linearizability of Object O A concurrent execution of O: Thread 1: Thread 2: ret push(7) push(6) ret (7) pop() Linearization point (LP) Sequential execution time push(6), ret, push(7), ret, pop(), ret(7)

Is Treiber’s stack linearizable? … v1 next vk Top push(v): 1 local b:=false, x, t; 2 x := new Node(v); 3 while (!b) { 4 t := top; 5 x.next = t; 6 b = cas(&top, t, x); 7 } Not update the shared list “Fixed”: statically located in impl code Line 6: the only command that changes the list LP

Challenges in Verifying Linearizability Non-fixed LPs Future-dependent LPs (e.g. lazy set, pair snapshot) LP is at a prior access, but only if a later validation succeeds  Need info from unpredictable future ? Helping (e.g. HSY elimination-backoff stack) t1 finishes t2’s opr  t2’s LP is in the code of t1  Break thread-modularity ? No program logic with formal soundness

Our Contributions A program logic for linearizability Support non-fixed LPs Formal meta-theory: a new simulation A light instrumentation mechanism to help verification Verified 12 well-known algorithms Some are used in java.util.concurrent

lin LP Treiber’s stack O Abstract stack S Stk = v1 :: v2 :: … :: vk … next vk Top Stk = v1 :: v2 :: … :: vk push(v): 1 local b:=false, x, t; 2 x := new Node(v); 3 while (!b) { 4 t := top; 5 x.next = t; 6 b = cas(&top, t, x); 7 } PUSH(v): Stk := v::Stk; LP

? lin LP Treiber’s stack O Abstract stack S … Stk = v :: Top next next … Stk = v :: v1 :: v2 :: … :: vk v1 vk v Abstract opr PUSH(v) not done Proved it’s LP LP 6 b := cas(&Top, t, x); if (b) linself; > 7 } < push(v): Execute abstract opr simultaneously 1 local b:=false, x, t; 2 x := new Node(v); 3 while (!b) { 4 t := Top; 5 x.next := t; Atomic block - { [PUSH(v)]  … } { []  … } Abstract opr is done

Basic Approach to Verify O lin S Inspired by [Vafeiadis’ Thesis] Instrument(O) = C with linself at LPs Verify C in program logic with rules for linself New assertions [S] and [] Ensure O’s LP step corresp. to S’s single step  Not support non-fixed LPs Future-dependent LPs Helping

Challenge 1: Future-Dependent LP Example: Pair Snapshot [Qadeer et al. MSR-TR-2009-142] t2: write(i, d) t1: readPair(i, j) m 1 … k write(i, d) updates m[i] to a new value d readPair(i, j) intends to return snapshot of m[i] and m[j]

know: m[i] = (a,v) at line 4 Pair Snapshot [Qadeer et al. MSR-TR-2009-142] readPair(int i, j){ 1 local s:=false, a, b, v, w; 2 while (!s) { 3 <a := m[i].d; v := m[i].v>; 4 <b := m[j].d; w := m[j].v>; 5 <if (v = m[i].v) s := true>; 6 } 7 return (a, b); } write(int i, d){ 8 <m[i].d := d; m[i].v++>; } LP if line 5 succeeds m 1 … k  Future-dependent LP Not supported by linself d know: m[i] = (a,v) at line 4 v version number Where is the LP ? Line 4? But line 5 may fail, m[i] and m[j] may be re-read

speculate at potential LP, keep both result and original Solution: Try-Commit readPair(int i, j){ 1 local s:=false, a, b, v, w; 2 while (!s) { 3 <a := m[i].d; v := m[i].v;> 4 <b := m[j].d; w := m[j].v; 5 <if (v = m[i].v) { s:= true; 6 } 7 return (a, b); } speculate at potential LP, keep both result and original - { m[i] = (a, v)  [RP, (i,j)]  … } [RP, (i,j)] > trylinself; - { m[i] = (a, v)  ( [, (a,b)] )  … }  } > commit( [, (a,b)] ); - { s  [, (a,b)]  s  … }

Challenge 2: Helping A push and a pop cancel each other Example: Elimination Stack [Hendler et al. SPAA’04] Elimination Array L t1: push(v) … v1 next vk Top t2 POP t2: pop() Find t2 is doing pop! Thread descriptor A push and a pop cancel each other

Challenge 2: Helping A push and a pop cancel each other Example: Elimination Stack [Hendler et al. SPAA’04] Elimination Array L t1: push(v) … v1 next vk Top t2 ret v t2: pop() When t2 comes, its job is done (helped by t1!). A push and a pop cancel each other

Challenge 2: Helping t1 & t2’s LPs: t1 updates L[t2] Example: Elimination Stack [Hendler et al. SPAA’04] Elimination Array L t1: push(v) t1 & t2’s LPs: t1 updates L[t2] t2 ret v t2: pop() Need to linearize a thread other than self A push and a pop cancel each other

set L[t2] from “POP” to “ret v” Solution: lin(t) t1: push(v) Elimination Array L t2: pop() t2 POP push(v): set L[t2] from “POP” to “ret v” < if (b) { lin(t1); lin(t2); } > b := cas(&L[t2], q, p); t1 & t2’s LPs

Solution: lin(t) ret v Elimination Array L t1: push(v) push(v): Abstraction of L. t2 ret v POP t2: pop() - { …  (L(t2) = POP)  t1 (PUSH, v)  t2 POP  … } < if (b) { lin(t1); lin(t2); } > b := cas(&L[t2], q, p); - { b  …  (L(t2) = ret v)  …  b  … } t1   t2 (, v)

Our Approach to Verify O lin S Instrument(O) = C with auxiliary cmds at LPs linself for fixed LPs try-commit for future-dependent LPs lin(t) for helping Assertions to describe abstract code & states p, q ::= … | t  S | t   | p  q | p  q Verify C in our program logic Extend an existing logic with rules for aux cmds

Our Logic for O lin S More rules and soundness are in the paper … ┝ {p  (t  S)} lin(t) {q * (t  )} ┝ {p} S {q} ┝ {p  (cid  S)} trylinself {( p * (cid  S) )  ( q * (cid  ) )} ┝ {p} S {q} ┝ {p  q} commit(p) {p} … More rules and soundness are in the paper

Verified Algorithms Objects Fut. LP Helping Java Pkg (JUC) Treiber stack  HSY stack MS two-lock queue MS lock-free queue DGLM queue Lock-coupling list Optimistic list Heller et al lazy list Harris-Michael lock-free list Pair snapshot CCAS RDCSS

Conclusion A program logic for linearizability A light instrumentation mechanism to help verification linself for fixed LPs lin(t) for helping try-commit for future-dependent LPs Verified 12 well-known algorithms

Backup Slides

Prophecy Variables Our Try-Commit readPair(int i, j){ 1 local s:=false, a, b, v, w; 2 while (!s) { 3 <a := m[i].d; v := m[i].v;> 4 <b := m[j].d; w := m[j].v; 4’ if (o) linself; > 5 <if (v = m[i].v) { 6 s := true; 6’ o =: true; } > 7 } 8 return (a, b); } No semantics for Hoare-style reasoning readPair(int i, j){ 1 local s:=false, a, b, v, w; 2 while (!s) { 3 <a := m[i].d; v := m[i].v;> 4 <b := m[j].d; w := m[j].v; 4’ trylinself; > 5 <if (v = m[i].v) { 6 s:= true; 6’ commit(cid  (, (a,b))); } > 7 } 8 return (a, b); } Formal semantics based on set of speculations

Related Work Vafeiadis Turon et al. (concurrent work) PhD Thesis : extensions of RGSep No soundness for linearizability Fut. LPs : prophecy variables without semantics [CAV’10] : automatic tool Non-fixed LPs for read-only methods only Turon et al. (concurrent work) [POPL’13] : Logical relation, no program logic [ICFP’13] : Logic, no instrumentation

State Model & Semantics Concrete state:  Auxiliary state:  (set of speculations)  = {(U, ), (U’, ’), …} U = {t1  S or , …, tn  S or } : abstract state (trylinself, (, {(U, )}))  (, {(U, ), (U’, ’)}) (S, )  ’ U(cid) = S U’ = U{cid  } (commit(p), (, ))  (, ’) ’ sat p ’  