Radar dataflow analysis for concurrent programs using datarace detection
Download
1 / 49

RADAR: Dataflow Analysis for Concurrent Programs using Datarace Detection - PowerPoint PPT Presentation


  • 159 Views
  • Uploaded on

RADAR: Dataflow Analysis for Concurrent Programs using Datarace Detection. Ravi Chugh, Jan Voung , Ranjit Jhala, Sorin Lerner {rchugh, jvoung, jhala, lerner} @ cs.ucsd.edu UC San Diego. Studying Concurrency is Important. Studying Concurrency is Important. Studying Concurrency is Important.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'RADAR: Dataflow Analysis for Concurrent Programs using Datarace Detection' - vanig


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Radar dataflow analysis for concurrent programs using datarace detection l.jpg

RADAR: Dataflow Analysis for Concurrent Programs using Datarace Detection

Ravi Chugh, Jan Voung, Ranjit Jhala, Sorin Lerner

{rchugh, jvoung, jhala, lerner} @ cs.ucsd.edu

UC San Diego





Studying concurrency is important5 l.jpg
Studying Concurrency is Important Datarace Detection

  • A “counting argument”

  • > wget http://pldi2008.cs.ucr.edu/program_schedule.html

  • > grep –i “concurr” program_schedule.html | wc –l

  • 6


All jokes aside l.jpg
All Jokes Aside… Datarace Detection

Architectural Trends

Pressing Issue

Devilish Bugs


Our approach l.jpg
Our Approach Datarace Detection

Leverage sequential work

Sequential

Dataflow

Analysis

Concurrent Dataflow Analysis


Sequential reasoning is incorrect l.jpg
Sequential Reasoning is Incorrect Datarace Detection

p = new_or_die();

p != null

x = compute();

p != null

*p = x;

if (p != null) {

use(p);

p = null;

}


Sequential optimization is incorrect l.jpg
Sequential Optimization is Incorrect Datarace Detection

flag = 0;

while (flag == 0) { /* spin */ }

use(g);

Constant propagation

would be incorrect

g = compute();

flag = 1;

0

  • Compilers forced to be conservative

  • Optimization opportunities missed


Our approach10 l.jpg
Our Approach Datarace Detection

Concurrent

Dataflow

Analysis

RADAR

Sequential

Dataflow

Analysis


Our approach11 l.jpg
Our Approach Datarace Detection

Sequential

Dataflow

Analysis

Concurrent

Dataflow

Analysis

RADAR

Concurrency

Analysis

Race

Detector


Modular framework l.jpg
Modular Framework Datarace Detection

Sequential

Non-Null

Analysis

Sequential

Constant

Analysis

Sequential

Dataflow

Analysis

Concurrent

Dataflow

Analysis

Concurrent

Non-Null

Analysis

Concurrent

Constant

Analysis

RADAR

Race

Detector


Modular framework13 l.jpg
Modular Framework Datarace Detection

Sequential

Constant

Analysis

RADAR

Concurrent

Constant

Analysis

Race

Detector

precise

scalable


Radar results l.jpg
RADAR: Results Datarace Detection

  • Concurrent non-null analysis

  • Scales to:

    • Apache (~130 KLOC)

    • OpenSSL (~210 KLOC)

    • subset of Linux kernel (~830 KLOC)


Example with locks l.jpg
Example with Locks Datarace Detection

lock(l);

p = new_or_die();

x = compute();

*p = x;

unlock(l);

lock(l);

if (p != null) {

use(p);

p = null;

}

unlock(l);


Can this be optimized l.jpg
Can this be Optimized? Datarace Detection

lock(l);

p = new_or_die();

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

lock(l);

if (p != null) {

use(p);

p = null;

}

unlock(l);


Optimized version is race free l.jpg
Optimized Version is Race-free Datarace Detection

lock(l);

p = new_or_die();

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

lock(l);

if (p != null) {

use(p);

p = null;

}

unlock(l);


Slide18 l.jpg
Oops… Datarace Detection

lock(l);

p = new_or_die();

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

lock(l);

if (p != null) {

use(p);

p = null;

}

unlock(l);


Sequential non null analysis l.jpg
Sequential Non-Null Analysis Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

p != null

unlock(l);

lock(l);

if (p != null) {

p != null

use(p);

p != null

p = null;

p != null

}

unlock(l);


Radar on example l.jpg
RADAR on Example Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

p != null

unlock(l);

lock(l);

if (p != null) {

p != null

use(p);

p != null

p = null;

p != null

}

unlock(l);


Radar on example21 l.jpg
RADAR on Example Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

Can fact be invalidated by concurrent thread?

Can p be written by a concurrent thread?


Radar on example22 l.jpg
RADAR on Example Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

Race

Detector

No Race

pseudo-read(p)

Race

Can p be written by a concurrent thread?


Radar on example23 l.jpg
RADAR on Example Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

Race

Detector

No Race

pseudo-read(p)

Race

Can p be written by a concurrent thread?


Radar on example24 l.jpg
RADAR on Example Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

lock(l);

*p = x;

unlock(l);

Race

Detector

No Race

Race

pseudo-read(p)


Radar on example25 l.jpg
RADAR on Example Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

unlock(l);

UNSAFE


Radar on safe example l.jpg
RADAR on Safe Example Datarace Detection

lock(l);

p = new_or_die();

p != null

x = compute();

*p = x;

unlock(l);

Race

Detector

No Race

pseudo-read(p)

Race


Radar on safe example27 l.jpg
RADAR on Safe Example Datarace Detection

lock(l);

p = new_or_die();

p != null

x = compute();

p != null

*p = x;

unlock(l);

Race

Detector

No Race

Race

pseudo-read(p)


Radar on safe example28 l.jpg
RADAR on Safe Example Datarace Detection

lock(l);

p = new_or_die();

p != null

x = compute();

p != null

*p = x;

unlock(l);

SAFE


More on radar l.jpg
More on RADAR Datarace Detection

  • Round trip queries to race detector

  • Inter-procedural analysis


1 round trip queries l.jpg
(1) Round-trip Queries Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

p != null

unlock(l);

Race

Detector

No Race

pseudo-read(p)

Race

Possible Race

pseudo-read(p)

Allow sequential analysis to run

Get superset of (concurrent) facts


1 round trip queries31 l.jpg
(1) Round-trip Queries Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

p != null

unlock(l);

Insert all pseudo-reads at once

pseudo-read(p)

Race

Detector

pseudo-read(p)

pseudo-read(p)

pseudo-read(p)

Send whole program to race detector

pseudo-read(p)


1 round trip queries32 l.jpg
(1) Round-trip Queries Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

p != null

unlock(l);

pseudo-read(p)

Get results back from Race Detector

pseudo-read(p)

pseudo-read(p)

pseudo-read(p)

pseudo-read(p)


1 round trip queries33 l.jpg
(1) Round-trip Queries Datarace Detection

lock(l);

p = new_or_die();

unlock(l);

x = compute();

lock(l);

*p = x;

unlock(l);

pseudo-read(p)

Get results back from Race Detector

pseudo-read(p)

pseudo-read(p)

Rerun analysis using race results

pseudo-read(p)

pseudo-read(p)


1 round trip queries34 l.jpg
(1) Round-trip Queries Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

lock(l);

*p = x;

unlock(l);

Rerun analysis using race results


1 round trip queries35 l.jpg
(1) Round-trip Queries Datarace Detection

lock(l);

p = new_or_die();

p != null

unlock(l);

p != null

x = compute();

p != null

lock(l);

p != null

*p = x;

unlock(l);

UNSAFE


2 handling procedures l.jpg
(2) Handling Procedures Datarace Detection

void foo() {

if (*) {

unlock(l);

compute();

lock(l);

}

}

lock(l);

if (p != null) {

foo();

*p = 10;

}

unlock(l);

lock(l);

p = null;

unlock(l);

Unlock in foo allows interference

Want to summarize effect of calling foo


2 handling procedures37 l.jpg
(2) Handling Procedures Datarace Detection

void foo() {

if (*) {

unlock(l);

compute();

lock(l);

}

}

lock(l);

if (p != null) {

foo();

*p = 10;

}

unlock(l);

lock(l);

p = null;

unlock(l);


2 handling procedures38 l.jpg
(2) Handling Procedures Datarace Detection

lock(l);

if (p != null) {

foo();

*p = 10;

}

unlock(l);

pseudo-unlock(l);

pseudo-read(p);

pseudo-lock(l);

  • In the caller, RADAR inserts:

    • pseudo-unlock for every unlock in foo

    • pseudo-reads


Evaluation l.jpg
Evaluation Datarace Detection

  • Is RADAR scalable?

  • Is RADAR precise?

  • Where can we do better?


Experiments benchmarks l.jpg
Experiments: Benchmarks Datarace Detection

  • Apache 2.2.6 (130 KLOC)

    • worker threads + modules (e.g., caches)

  • OpenSSL 0.9.8g (210 KLOC)

    • model a multi-threaded client

  • Linux 2.6.15 (830 KLOC)

    • subset from RELAY experiments


Slide41 l.jpg

Sequential Datarace Detection

Race Detector

+

=

Non-Null

Escapes ⇒ race

Conservative

Non-Null

Non-Null

Optimistic (sequential)

Never race

Non-Null


Slide42 l.jpg

GAP Datarace Detection

Sequential

Race Detector

+

=

Non-Null

Escapes ⇒ race

Conservative

Shared ⇒ race

Non-Null

No locks ⇒race

Non-Null

Optimistic (sequential)

Never race

Non-Null


Slide43 l.jpg

Sequential Datarace Detection

Race Detector

+

=

Non-Null

Escapes ⇒ race

Conservative

Shared ⇒ race

Non-Null

No locks ⇒race

Non-Null

Optimistic (sequential)

Never race

Non-Null


Sources of imprecision l.jpg
Sources of Imprecision Datarace Detection

  • Alias analysis

    • affects sequential dataflow and race detection

  • Lockset-based race analysis

    • ignores fork, join, condition variables

  • RADAR framework

    • pseudo-read (for non-null fact) races with

    • “x = NonNullAddress;”


Related work l.jpg
Related Work Datarace Detection

  • Programming-model-based approaches

    • [Knoop et al 96], [Grunwald et al 93], …

    • par-begin / par-end

    • handles introduction of facts between threads

  • Thread-modular

    • [Owicki et al 76], [Jones 83], [Flanagan et al 03], …

    • more precise (use environment assumption)

    • inference not as scalable


Conclusion l.jpg
Conclusion Datarace Detection

Sequential

Dataflow

Analysis

RADAR

Concurrent

Dataflow

Analysis

Race

Detector

precise

scalable


Slide47 l.jpg

THANKS! Datarace Detection


What is filtered for non null l.jpg
What is filtered for non-null? Datarace Detection

if (a->f != null) {

b->f = null;

deref(a->f); //filter if warned

deref(b->f); //don’t filter

}


ad