deadloc k immunity - itec-os start · deadloc k immunity enabling systems t o defend against...
TRANSCRIPT
Horatiu Jula, Daniel Tralamazza,Cristian Zamfir, George Candea
Dependable Systems Laboratory
Deadlock ImmunityEnabling Systems To Defend Against Deadlocks
Outline
Immunity Against Deadlocks
Dimmunix Overview
Challenges & Solutions
Discussion & Conclusions
4
Deadlock Immunity
Learn executions that lead to deadlock
Save fingerprints of encountered deadlock patterns into a persistent history
Avoid executions patterns that have led to deadlock in the past
5
Example Uses
Software vendorsExample: Protect a deadlock-free Web browser
Users extend browsers with plugins not controlled by the vendor... these can deadlock the browserDeadlock occurs → obtain fingerprint → distribute it to all
End usersExample: Deadlock-prone closed-source legacy DB server
Develop immunity against deadlocksNo need to upgrade or wait for patches
6
7
void nlShutdown(void){ if(--nlInitCount > 0) return;
if(nlSockets != NULL) { NLsocket i; for(i=0;i<nlNextsocket;i++) { if(nlSockets[i] != NULL) {
driver->Close(i); nlReturnSocket(i); nlUnlockSocket(i, NL_BOTH); nlFreeSocket(i); } } free(nlSockets); nlSockets = NULL; } nlMutexUnlock(&socklock); if(driver != NULL) { driver->Shutdown(); driver->initialized = NL_FALSE; driver = NULL; } else { ....
NLboolean nlClose(NLsocket socket){ if(driver) { if(nlIsValidSocket(socket) == NL_TRUE) {
driver->Close(socket);
nlReturnSocket(socket); nlMutexUnlock(&socklock); nlUnlockSocket(socket, NL_BOTH); return NL_TRUE; } else { nlSetError(NL_INVALID_SOCKET); return NL_TRUE; } } nlSetError(NL_NO_NETWORK); return NL_FALSE;}
nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH);
nlMutexLock(&socklock);
nlLockSocket(i, NL_BOTH);
8
void nlShutdown(void){ if(--nlInitCount > 0) return;
if(nlSockets != NULL) { NLsocket i; for(i=0;i<nlNextsocket;i++) { if(nlSockets[i] != NULL) {
driver->Close(i); nlReturnSocket(i); nlUnlockSocket(i, NL_BOTH); nlFreeSocket(i); } } free(nlSockets); nlSockets = NULL; } nlMutexUnlock(&socklock); if(driver != NULL) { driver->Shutdown(); driver->initialized = NL_FALSE; driver = NULL; } else { ....
NLboolean nlClose(NLsocket socket){ if(driver) { if(nlIsValidSocket(socket) == NL_TRUE) {
driver->Close(socket);
nlReturnSocket(socket); nlMutexUnlock(&socklock); nlUnlockSocket(socket, NL_BOTH); return NL_TRUE; } else { nlSetError(NL_INVALID_SOCKET); return NL_TRUE; } } nlSetError(NL_NO_NETWORK); return NL_FALSE;}
nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH);
nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH);
8
nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH); nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH);
Thread 1 Thread 2
8
nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH); nlMutexLock(&socklock);
nlLockSocket(socket, NL_BOTH);
Thread 1 Thread 2
Lock Inversion => Deadlock Bug
9
nlMutexLock(&socklock)
nlLockSocket(socket, NL_BOTH) nlMutexLock(&socklock)
nlLockSocket(i, NL_BOTH)
9
nlMutexLock(&socklock)
nlLockSocket(socket, NL_BOTH)
nlMutexLock(&socklock)
nlLockSocket(i, NL_BOTH)
nlClose(socket)
nlMutexLock(socks[socket]->lock)
pthread_mutex_lock(socklock->p_mutex)
pthread_mutex_lock(sock[socket]->lock->mutex)
nlShutdown()
nlMutexLock(socks[i]->lock)
pthread_mutex_lock(socklock->p_mutex)
pthread_mutex_lock(socks[i]->lock->p_mutex)
Thread
1Th
read
2
9
nlMutexLock(&socklock)
nlLockSocket(socket, NL_BOTH)
nlMutexLock(&socklock)
nlLockSocket(i, NL_BOTH)
nlClose(socket)
nlMutexLock(socks[socket]->lock)
pthread_mutex_lock(socklock->p_mutex)
pthread_mutex_lock(sock[socket]->lock->mutex)
nlShutdown()
nlMutexLock(socks[i]->lock)
pthread_mutex_lock(socklock->p_mutex)
pthread_mutex_lock(socks[i]->lock->p_mutex)
Thread
1Th
read
2
9
nlMutexLock(&socklock)
nlLockSocket(socket, NL_BOTH)
nlMutexLock(&socklock)
nlLockSocket(i, NL_BOTH)
nlClose(socket)
nlMutexLock(socks[socket]->lock)
pthread_mutex_lock(socklock->p_mutex)
pthread_mutex_lock(sock[socket]->lock->mutex)
nlShutdown()
nlMutexLock(socks[i]->lock)
pthread_mutex_lock(socklock->p_mutex)
pthread_mutex_lock(socks[i]->lock->p_mutex)
Thread
1Th
read
2
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
Thread
1Th
read
2
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
Thread
1Th
read
2
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
Thread
1Th
read
2
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
Thread
1Th
read
2
Deadlock Bug
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
Thread
1Th
read
2
Deadlock Bug
Hangs
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
Thread
1Th
read
2
Deadlock Bug
Hangs
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
Thread
1Th
read
2
Deadlock Bug
Hangs
DeadlockPattern
10
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
Thread
1Th
read
2
Deadlock Bug
Hangs
11
DimmunixIntercepts calls to lock/unlock
Detects deadlocks automatically
Saves the observed deadlock pattern
Avoids executions that match saved patterns
11
DimmunixIntercepts calls to lock/unlock
Detects deadlocks automatically
Saves the observed deadlock pattern
Avoids executions that match saved patterns
History of patterns = immune system
InterceptionTwo versions
Java: Direct instrumentationPOSIX Threads: Modified pthreads shared library
BenefitsZero assistance from programmersZero assistance from usersZero need for source code
12
Fingerprinting Deadlocks
14
t2
t1
l2
l1pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
Fingerprinting Deadlocks
14
t2
t1
l2
l1pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
Fingerprinting Deadlocks
14
t2
t1
l2
l1pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
Fingerprinting Deadlocks
14
t2
t1
l2
l1pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
Fingerprinting Deadlocks
14
t2
t1
l2
l1pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
Fingerprinting Deadlocks
14
t2
t1
l2
l1pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
Fingerprinting Deadlocks
14
t2
t1
l2
l1
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
Fingerprinting Deadlocks
14
t2
t1
l2
l1
pthread_mutex_lock
[email protected]:[email protected]:105History of Signatures
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 553
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
nlMutexLock@ nl.c : 553
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
Thread
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
pthread_mutex_unlock
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
pthread_mutex_unlock
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722Th
read
1Th
read
2
pthread_mutex_unlock
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 722
nlLockSocket@ nl.c : 565
Thread
1Th
read
2
pthread_mutex_unlock
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 347
nlMutexLock@ nl.c : 722
nlLockSocket@ nl.c : 565
Thread
1Th
read
2
pthread_mutex_unlock
Avoidance
15
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
nlClose
nlShutdown
nlLockSocket@ nl.c : 710
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 553
nlMutexLock@ nl.c : 347
pthread_mutex_lock@ mutex.c : 105
nlMutexLock@ nl.c : 722
nlLockSocket@ nl.c : 565
Thread
1Th
read
2
pthread_mutex_unlock
17
System Bug# Deadlock Bug Description
MySQL 6.0.4 37080 INSERT and TRUNCATE in two different threads
SQLite 3.3.0 1672 Race condition in custom recursive lock implementation
HawkNL 1.6b3 n/a nlShutdown() called concurrently with nlClose()
Limewire 4.17.9 1449 Cancel HsqlDB TaskQueue concurrently with program shutdown()
ActiveMQ 3.1 336 Concurrently create listener and actively dispatch messages to consumer
ActiveMQ 4.0 575 Concurrent invocation of Queue.dropEvent() and PrefetchSubscription.add()
MySQL 5.0 JDBC
2147 Connection.close() called concurrently with PreparedStatement.getWarnings()
14972 Connection.prepareStatement() called concurrently with Statement.close()
31136 PreparedStatement.executeQuery() called concurrently w/ Connection.close()
17709 Statement.executeQuery() concurrent with Connection.prepareStatement()
17
System Bug# Deadlock Bug Description
MySQL 6.0.4 37080 INSERT and TRUNCATE in two different threads
SQLite 3.3.0 1672 Race condition in custom recursive lock implementation
HawkNL 1.6b3 n/a nlShutdown() called concurrently with nlClose()
Limewire 4.17.9 1449 Cancel HsqlDB TaskQueue concurrently with program shutdown()
ActiveMQ 3.1 336 Concurrently create listener and actively dispatch messages to consumer
ActiveMQ 4.0 575 Concurrent invocation of Queue.dropEvent() and PrefetchSubscription.add()
MySQL 5.0 JDBC
2147 Connection.close() called concurrently with PreparedStatement.getWarnings()
14972 Connection.prepareStatement() called concurrently with Statement.close()
31136 PreparedStatement.executeQuery() called concurrently w/ Connection.close()
17709 Statement.executeQuery() concurrent with Connection.prepareStatement()
Avoids real deadlocks in real systems
Challenges
1. Performance
2. Induced Starvation
3. Precision Calibration
See paper for...Weak vs. strong immunitySoftware upgradesEvaluation of false positives
18
1. PerformancePotential overhead
Intercept every call to lock/unlockUpdate resource allocation graphFind cycles + make suspend/resume decisions
Solution: asynchronous architectureDo expensive work in a separate threadTake advantage of multi-core CPULock-free data structures
19
20
lock(L)
unlock(L)
Avoidance
Monitor Thread
deciderequest
acquired
release
go / yieldasynceventqueue
Application Thread
read
-only
lock-free
periodically do :
process events search for cycles if cycles found save to history
{
}
RAG cache
History
RAG
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
)"
()"
%))"
%()"
!))"
!()"
)"
%)))"
!)))"
')))"
#)))"
()))"
&)))"
*)))"
$)))"
+)))"
!" #" $" %&" '!" &#" %!$" !(&" (%!" %)!#"
,-./012/"
31445216"
75.8/29."
Lock
Ope
ratio
ns /
Sec
ond
Number of Threads
Thread Suspends / Second
1. Performance
21
Overhead = 0.6% - 4.5%
1. PerformanceMatching signatures from history
Hash call stacks and index into precomputed tablesThread-local cache of data structures
22
1. PerformanceMatching signatures from history
Hash call stacks and index into precomputed tablesThread-local cache of data structures
22
Lock
Ope
ratio
ns /
Sec
ond
!"""#
!$""#
!%""#
!&""#
!'""#
'"""#
'$""#
'%""#
'&""#
''""#
("""#
$# %# '# )&# *$# &%# )$'# $+&#
,-./012/#
31445216#
Number of Signatures in History
1. PerformanceMatching signatures from history
Hash call stacks and index into precomputed tablesThread-local cache of data structures
22
Lock
Ope
ratio
ns /
Sec
ond
!"""#
!$""#
!%""#
!&""#
!'""#
'"""#
'$""#
'%""#
'&""#
''""#
("""#
$# %# '# )&# *$# &%# )$'# $+&#
,-./012/#
31445216#
Number of Signatures in History
1. PerformanceMatching signatures from history
Hash call stacks and index into precomputed tablesThread-local cache of data structures
22
Lock
Ope
ratio
ns /
Sec
ond
!"""#
!$""#
!%""#
!&""#
!'""#
'"""#
'$""#
'%""#
'&""#
''""#
("""#
$# %# '# )&# *$# &%# )$'# $+&#
,-./012/#
31445216#
Number of Signatures in History
2. Induced Starvation
All approaches based on yield/suspend can induce starvation
i.e., a thread actively yields, waiting for a blocked thread to make progress
Never encountered in our tests
23
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
24
t2
t1
l2
l1
l3ThreadLock
Request edgeHold edge
Yield edge
Detect & avoid starvationas if it was a deadlock
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
3. Precision Calibration
False positive = avoiding a deadlock that would not have occurred
Two sources:Matching signatures too generallyInput dependencies
25
26
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
26
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
pthread_mutex_lock
[email protected]:[email protected]:105
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
stop_player@ cmd.c : 122
event_loop@ event.c : 70
main@ main.c : 28
srv_shutdown@ cmd.c : 80
@ event.c : 87
26
nlMutexLock
nlLockSocket
nlMutexLock
nlLockSocket
nlClose
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
nlShutdown
nlMutexLock
pthread_mutex_lock
pthread_mutex_lock
@ nl.c : 710
@ nl.c : 347
@ mutex.c : 105
@ mutex.c : 105
@ mutex.c : 105
@ nl.c : 553
@ nl.c : 347
@ mutex.c : 105
@ nl.c : 722
@ nl.c : 565
stop_player@ cmd.c : 122
event_loop@ event.c : 70
main@ main.c : 28
srv_shutdown@ cmd.c : 80
@ event.c : 87
pthread_mutex_lock
nlClose @nl.c:[email protected]:[email protected]:105
[email protected]:122event_loop @event.c:[email protected]:28
pthread_mutex_lock
[email protected]:[email protected]:105
[email protected]:80event_loop @event.c:[email protected]:28
3. Precision Calibration
Solution: Automatic precision adjustmentPost-factum what-if analysisHeuristic: look for potential lock inversions
Input dependencies not capturedDimmunix focused 100% on control flowThis is a requisite for portability of signatures, i.e., for immunity
27
Outline
Immunity Against Deadlocks
Dimmunix Overview
Challenges & Solutions
Discussion & Conclusions
28
Dimmunix Properties
1. Someone will experience first occurrence Afterward can vaccinate all others
2. Cannot affect deadlock-free programs
3. Cannot induce incorrect outputs (non-RT)
4. Must be aware of all synch mechanisms
29
Related Work
Complements other reliability techniquesStatic analysis [Flanagan & Leino] [Engler & Ashcraft]Modelchecking [Henzinger et al.] [Havelund et al.]Transactional Memory [Herlihy & Moss]
Improves upon previous approaches by increasing avoidance precision
Program transformations [Boronat & Cholvi]Ghostlocks [Zeng & Martin]Gatelocks [Buchbinder et al.]
30