Th The E e Eph phemer emeral al Smo mokin ing Gu g Gun
Using ng ftra trace e and nd kgdb to to res resolve a pthre thread “dea eadlock” Bra rad Mouri uring LabVIEW Rea eal- Ti Time Nati tional In Instrum trument ents
Th The E e Eph phemer emeral al Smo mokin ing Gu g Gun - - PowerPoint PPT Presentation
Th The E e Eph phemer emeral al Smo mokin ing Gu g Gun Using ng ftra trace e and nd kgdb to to res resolve a pthre thread dea eadlock Bra rad Mouri uring LabVIEW Rea eal- Ti Time Nati tional In Instrum trument
Using ng ftra trace e and nd kgdb to to res resolve a pthre thread “dea eadlock” Bra rad Mouri uring LabVIEW Rea eal- Ti Time Nati tional In Instrum trument ents
2
– Work with maintainers, minimize out-of-tree
The Ephemeral Smoking Gun Brad Mouring
3
The Ephemeral Smoking Gun Brad Mouring
4
The Ephemeral Smoking Gun Brad Mouring
5
– Checking for a reported deadlock on certain lock
The Ephemeral Smoking Gun Brad Mouring
6
The Ephemeral Smoking Gun Brad Mouring
7
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor
The Ephemeral Smoking Gun Brad Mouring
8
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M
The Ephemeral Smoking Gun Brad Mouring
9
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in
The Ephemeral Smoking Gun Brad Mouring
10
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in C becomes runnable, is scheduled in
The Ephemeral Smoking Gun Brad Mouring
11
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in C becomes runnable, is scheduled in C blocks on mutex M
The Ephemeral Smoking Gun Brad Mouring
12
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in C becomes runnable, is scheduled in C blocks on mutex M B is scheduled in (prio 11), blocking C (prio 90) from running!
The Ephemeral Smoking Gun Brad Mouring
13
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in C becomes runnable, is scheduled in C blocks on mutex M
The Ephemeral Smoking Gun Brad Mouring
14
T ask A (prio 90) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in C becomes runnable, is scheduled in C blocks on mutex M A receives C's priority, fjnishes with mutex M, releases M
The Ephemeral Smoking Gun Brad Mouring
15
T ask A (prio 10) T ask B (prio 11) T ask C (prio 90) A is running on the processor A takes mutex M B becomes runnable, is scheduled in C becomes runnable, is scheduled in C blocks on mutex M A receives C's priority, fjnishes with mutex M, releases M A receives its previous priority, C is scheduled in
The Ephemeral Smoking Gun Brad Mouring
16
The Ephemeral Smoking Gun Brad Mouring
17
The Ephemeral Smoking Gun Brad Mouring
18
task task task mutex task mutex
Blocked-on Owns
The Ephemeral Smoking Gun Brad Mouring
19
task task mutex mutex
Blocked-on Owns
The Ephemeral Smoking Gun Brad Mouring
task
20
The Ephemeral Smoking Gun Brad Mouring
21
– e.g. CONFIG_KGDB_SERIAL_CONSOLE
The Ephemeral Smoking Gun Brad Mouring
22
¹http://sysprogs.com/VisualKernel/kgdboe/
The Ephemeral Smoking Gun Brad Mouring
23
The Ephemeral Smoking Gun Brad Mouring
24
… and that's not necessarily a bad thing.
The Ephemeral Smoking Gun Brad Mouring
25
A B D C M2 M3 M1 Iterator used to walk priority chain
Blocked-on Owns
T ask about to get EDEADLK
The Ephemeral Smoking Gun Brad Mouring
26
The Ephemeral Smoking Gun Brad Mouring
27
The Ephemeral Smoking Gun Brad Mouring
28
29
The Ephemeral Smoking Gun Brad Mouring
30
A B C M2 M1
task iter
B blocks on M1 M1 is held by C C is blocked on M2 M2 is held by A Blocked-on Owns
The Ephemeral Smoking Gun Brad Mouring
31
A B C M2 M1
B blocks on M1 M1 is held by C C is blocked on M2 M2 is held by A B begins walking the prio chain
task iter
Blocked-on Owns
The Ephemeral Smoking Gun Brad Mouring
32
A B C M2 M1
B blocks on M1 M1 is held by C C is blocked on M2 M2 is held by A B begins walking the prio chain...PREEMPT!
(B)
Blocked-on Owns
task iter (B)
The Ephemeral Smoking Gun Brad Mouring
33
A B C M2 M1
A is scheduled in, releases M2
(B) task iter (B)
Blocked-on Owns
The Ephemeral Smoking Gun Brad Mouring
34
B C M2 M1
A is scheduled in, releases M2 A takes (uncontended) M3 in userspace A blocks on M1
A
(B) task iter (B)
The Ephemeral Smoking Gun Brad Mouring
35
D is scheduled in, blocks on M3 (creates rtmutex)
D M3 B C M2 M1 A
(B) task iter (B)
The Ephemeral Smoking Gun Brad Mouring
36
B is scheduled back in, continues its walk of the prio chain
D M3 B C M2 M1 A task iter
The Ephemeral Smoking Gun Brad Mouring
37
B is scheduled back in, continues its walk of the prio chain
D M3 B C M2 M1 A task iter
The Ephemeral Smoking Gun Brad Mouring
A blocks on the same mutex as B!
38
B is scheduled back in, continues its walk of the prio chain
D M3 B C M2 M1 A task iter
The Ephemeral Smoking Gun Brad Mouring
A blocks on the same mutex as B!
39
The Ephemeral Smoking Gun Brad Mouring
40
The Ephemeral Smoking Gun Brad Mouring
41
The Ephemeral Smoking Gun Brad Mouring