Top Banner
AVIO: Detecting Atomicity Violations via Access Interleaving Invariants Dacong (Tony) Yan January 25, 2011
37

AVIO class present

Nov 29, 2014

Download

Technology

Dacong Yan

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: AVIO class present

AVIO: Detecting Atomicity Violations via AccessInterleaving Invariants

Dacong (Tony) Yan

January 25, 2011

Page 2: AVIO class present

Motivation

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 2/21

Page 3: AVIO class present

Motivation

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 3/21

Page 4: AVIO class present

Agenda

Motivation

AVIO Idea

AVIO Algorithms

AVIO Implementations

Discussion

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 4/21

Page 5: AVIO class present

AVIO Idea

Idea: access interleaving invariants!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 5/21

Page 6: AVIO class present

AVIO Idea

Idea: access interleaving invariants!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 5/21

Page 7: AVIO class present

Eight Cases of Access Interleavings

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 6/21

Page 8: AVIO class present

AVIO Idea

Two Phases

Training: extracts access interleaving invariants from a large set ofcorrect runs;Detection: monitors the program execution, and checks whether thefour buggy cases occur.

Discussion

Correctness: are correct runs indeed correct?Sufficiency: is the number of correct runs large enough?

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 7/21

Page 9: AVIO class present

AVIO Idea

Two Phases

Training: extracts access interleaving invariants from a large set ofcorrect runs;

Detection: monitors the program execution, and checks whether thefour buggy cases occur.

Discussion

Correctness: are correct runs indeed correct?Sufficiency: is the number of correct runs large enough?

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 7/21

Page 10: AVIO class present

AVIO Idea

Two Phases

Training: extracts access interleaving invariants from a large set ofcorrect runs;Detection: monitors the program execution, and checks whether thefour buggy cases occur.

Discussion

Correctness: are correct runs indeed correct?Sufficiency: is the number of correct runs large enough?

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 7/21

Page 11: AVIO class present

AVIO Idea

Two Phases

Training: extracts access interleaving invariants from a large set ofcorrect runs;Detection: monitors the program execution, and checks whether thefour buggy cases occur.

Discussion

Correctness: are correct runs indeed correct?Sufficiency: is the number of correct runs large enough?

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 7/21

Page 12: AVIO class present

AVIO Algorithms

Page 13: AVIO class present

Detection Algorithm

What is an access inverleaving invariant?

A pair of accesses (P-Instruction, I-Instruction).

Detection procedure:

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 9/21

Page 14: AVIO class present

Detection Algorithm

What is an access inverleaving invariant?

A pair of accesses (P-Instruction, I-Instruction).

Detection procedure:

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 9/21

Page 15: AVIO class present

Detection Algorithm

What is an access inverleaving invariant?

A pair of accesses (P-Instruction, I-Instruction).

Detection procedure:

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 9/21

Page 16: AVIO class present

Extraction Algorithm

Idea: eliminate non-invariants from the whole set of pairs ofaccesses.

1. Suppose ai is an invariant: ai ∈ AISet;2. If ai is violated in correct runs, remove ai from AISet.

Pseudocode

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 10/21

Page 17: AVIO class present

Extraction Algorithm

Idea: eliminate non-invariants from the whole set of pairs ofaccesses.

1. Suppose ai is an invariant: ai ∈ AISet;2. If ai is violated in correct runs, remove ai from AISet.

Pseudocode

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 10/21

Page 18: AVIO class present

Extraction Algorithm

Idea: eliminate non-invariants from the whole set of pairs ofaccesses.

1. Suppose ai is an invariant: ai ∈ AISet;2. If ai is violated in correct runs, remove ai from AISet.

Pseudocode

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 10/21

Page 19: AVIO class present

AVIO Implementations

Page 20: AVIO class present

AVIO-H

L1 cache line extension

Hardware-based decision procedure

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 12/21

Page 21: AVIO class present

AVIO-H

L1 cache line extension

Hardware-based decision procedure

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 12/21

Page 22: AVIO class present

AVIO-S

Two access tables

Local access table: latest access information per threadGlobal access table: thread id of latest write among all threads

Detection at I-instruction

P-instruction: extracts from local access tableRemote access: extracts from global access table

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 13/21

Page 23: AVIO class present

AVIO-S

Two access tables

Local access table: latest access information per threadGlobal access table: thread id of latest write among all threads

Detection at I-instruction

P-instruction: extracts from local access tableRemote access: extracts from global access table

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 13/21

Page 24: AVIO class present

Discussion

Page 25: AVIO class present

Q1: How can we fix this bug?

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 15/21

Page 26: AVIO class present

Solution: busy-waiting

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 16/21

Page 27: AVIO class present

Q2: Will AVIO report this violation?

Q2.1: Will < (shared == null)rd , (shared = newObj)wr > beincluded in AISet? Yes!

Q2.2: Will the buggy interleaving be detected? Yes!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 17/21

Page 28: AVIO class present

Q2: Will AVIO report this violation?

Q2.1: Will < (shared == null)rd , (shared = newObj)wr > beincluded in AISet?

Yes!

Q2.2: Will the buggy interleaving be detected? Yes!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 17/21

Page 29: AVIO class present

Q2: Will AVIO report this violation?

Q2.1: Will < (shared == null)rd , (shared = newObj)wr > beincluded in AISet? Yes!

Q2.2: Will the buggy interleaving be detected? Yes!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 17/21

Page 30: AVIO class present

Q2: Will AVIO report this violation?

Q2.1: Will < (shared == null)rd , (shared = newObj)wr > beincluded in AISet? Yes!

Q2.2: Will the buggy interleaving be detected?

Yes!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 17/21

Page 31: AVIO class present

Q2: Will AVIO report this violation?

Q2.1: Will < (shared == null)rd , (shared = newObj)wr > beincluded in AISet? Yes!

Q2.2: Will the buggy interleaving be detected? Yes!

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 17/21

Page 32: AVIO class present

Q3: Why does AVIO-H have much lower overhead?

Answer: extra bits needed by the algorithm can be piggybacked in thecache coherence protocol, inducing very little extra cost.

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 18/21

Page 33: AVIO class present

Q3: Why does AVIO-H have much lower overhead?

Answer: extra bits needed by the algorithm can be piggybacked in thecache coherence protocol, inducing very little extra cost.

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 18/21

Page 34: AVIO class present

Q4: Why does AVIO-H report more false positives?

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 19/21

Page 35: AVIO class present

Q4: Why does AVIO-H report more false positives?

Will an atomicity violation warning be raised by AVIO-H?

False sharing

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 20/21

Page 36: AVIO class present

Q4: Why does AVIO-H report more false positives?

Will an atomicity violation warning be raised by AVIO-H?

False sharing

CSE 788.07, Dacong (Tony) Yan AVIO: Detecting Atomicity Violations via Access Interleaving Invariants 20/21

Page 37: AVIO class present

Thank you!