© 2008 Multifacet ProjectUniversity of Wisconsin-Madison Pathological Interaction of Locks with Transactional Memory Haris Volos, Neelam Goyal, Michael.

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Software Transactional Memory Kevin Boos. Two Papers Software Transactional Memory for Dynamic-Sized Data Structures (DSTM) – Maurice Herlihy et al –
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture X: Transactions.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
Transactional Memory (TM) Evan Jolley EE 6633 December 7, 2012.
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
PARALLEL PROGRAMMING with TRANSACTIONAL MEMORY Pratibha Kona.
[ 1 ] Agenda Overview of transactional memory (now) Two talks on challenges of transactional memory Rebuttals/panel discussion.
1 Lecture 7: Transactional Memory Intro Topics: introduction to transactional memory, “lazy” implementation.
1 Lecture 8: Eager Transactional Memory Topics: implementation details of eager TM, various TM pathologies.
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
Transaction Management and Concurrency Control
Supporting Nested Transactional Memory in LogTM Authors Michelle J Moravan Mark Hill Jayaram Bobba Ben Liblit Kevin Moore Michael Swift Luke Yen David.
1 Lecture 6: TM – Eager Implementations Topics: Eager conflict detection (LogTM), TM pathologies.
CS510 Concurrent Systems Class 13 Software Transactional Memory Should Not be Obstruction-Free.
TxLinux: Using and Managing Hardware Transactional Memory in an Operating System Christopher J. Rossbach, Owen S. Hofmann, Donald E. Porter, Hany E. Ramadan,
Language Support for Lightweight transactions Tim Harris & Keir Fraser Presented by Narayanan Sundaram 04/28/2008.
Christopher J. Rossbach, Owen S. Hofmann, Donald E. Porter, Hany E. Ramadan, Aditya Bhandari, and Emmett Witchel - Presentation By Sathish P.
The Cost of Privatization Hagit Attiya Eshcar Hillel Technion & EPFLTechnion.
XCalls: Safe I/O in Memory Transactions Haris Volos, Andres Jaan Tack, Neelam Goyal +, Michael Swift, Adam Welc § University of Wisconsin - Madison + §
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
LogTM: Log-Based Transactional Memory Kevin E. Moore, Jayaram Bobba, Michelle J. Moravan, Mark D. Hill, & David A. Wood Presented by Colleen Lewis.
Why The Grass May Not Be Greener On The Other Side: A Comparison of Locking vs. Transactional Memory Written by: Paul E. McKenney Jonathan Walpole Maged.
Software Transactional Memory for Dynamic-Sized Data Structures Maurice Herlihy, Victor Luchangco, Mark Moir, William Scherer Presented by: Gokul Soundararajan.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Reduced Hardware NOrec: A Safe and Scalable Hybrid Transactional Memory Alexander Matveev Nir Shavit MIT.
CS5204 – Operating Systems Transactional Memory Part 2: Software-Based Approaches.
Condition Variables and Transactional Memory: Problem or Opportunity? Polina Dudnik and Michael Swift University of Wisconsin, Madison.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Low-Overhead Software Transactional Memory with Progress Guarantees and Strong Semantics Minjia Zhang, 1 Jipeng Huang, Man Cao, Michael D. Bond.
Kernel Locking Techniques by Robert Love presented by Scott Price.
Chapter 7 -1 CHAPTER 7 PROCESS SYNCHRONIZATION CGS Operating System Concepts UCF, Spring 2004.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
CS510 Concurrent Systems Why the Grass May Not Be Greener on the Other Side: A Comparison of Locking and Transactional Memory.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
StealthTest: Low Overhead Online Software Testing Using Transactional Memory Jayaram Bobba, Weiwei Xiong*, Luke Yen †, Mark D. Hill, and David A. Wood.
Software Transactional Memory Should Not Be Obstruction-Free Robert Ennals Presented by Abdulai Sei.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
© 2006 Mulitfacet ProjectUniversity of Wisconsin-Madison LogTM: Log-Based Transactional Memory Kevin E. Moore, Jayaram Bobba, Michelle J. Moravan, Mark.
Solving Difficult HTM Problems Without Difficult Hardware Owen Hofmann, Donald Porter, Hany Ramadan, Christopher Rossbach, and Emmett Witchel University.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
On Transactional Memory, Spinlocks and Database Transactions Khai Q. Tran Spyros Blanas Jeffrey F. Naughton (University of Wisconsin Madison)
Architectural Features of Transactional Memory Designs for an Operating System Chris Rossbach, Hany Ramadan, Don Porter Advanced Computer Architecture.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Multiprocessors – Locks
Irina Calciu Justin Gottschlich Tatiana Shpeisman Gilles Pokam
Minh, Trautmann, Chung, McDonald, Bronson, Casper, Kozyrakis, Olukotun
Part 2: Software-Based Approaches
Transaction Management and Concurrency Control
Why The Grass May Not Be Greener On The Other Side: A Comparison of Locking vs. Transactional Memory By McKenney, Michael, Triplett and Walpole.
Hardware Transactional Memory
Kernel Synchronization II
Chapter 10 Transaction Management and Concurrency Control
Threading And Parallel Programming Constructs
Christopher J. Rossbach, Owen S. Hofmann, Donald E. Porter, Hany E
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Software Transactional Memory Should Not be Obstruction-Free
Locking Protocols & Software Transactional Memory
Kernel Synchronization II
Performance Pathologies in Hardware Transactional Memory
Performance Pathologies in Hardware Transactional Memory
Decomposing Hardware Lock Elision
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

© 2008 Multifacet ProjectUniversity of Wisconsin-Madison Pathological Interaction of Locks with Transactional Memory Haris Volos, Neelam Goyal, Michael M. Swift Multifacet Project ( Computer Sciences Department University of Wisconsin—Madison

2 Brain teaser What causes the following to deadlock in LogTM?... atomic {... memcmp(s1, s2, n);... } Dynamic Linker lock

3 Brain teaser What causes the following to deadlock in LogTM? Thread 1 Thread 2... atomic {... memcmp(); elf_bndr()‏ enter()‏ rt_mutex_lock( &rtldlock )... free(); elf_bndr()‏ enter()‏ rt_mutex_lock( &rtldlock )‏... rt_mutex_unlock( &rtldlock )‏ NACK Not unique to LogTM

4 Executive Summary Problem –Interaction of locks with transactional memory –Legacy code uses locks Interaction Pathologies –Identified five pathologies –Affect a spectrum of TM systems Transaction-safe Lock (TxLock)‏ –Execute lock-based critical sections inside transactions –Modified OpenSolaris libC

5 Outline Interaction Pathologies Transaction-Safe Lock (TxLock)‏ Conclusion

6 Interaction Pathologies Pathological interaction –Correct code making proper use of locks breaks under transactions Identified five Interaction Pathologies – Blocking – Deadlock – Livelock – Early Release – Invisible Locking Affect a spectrum of TM systems STM HTM

7 Transactional Memory Design Version Management –Eager, in-place update –Lazy, deferred update Conflict Detection –Eager, early –Lazy, late Conflict Resolution –Requester wins –Requester loses Atomicity –Strong –Weak

8 Deadlock Impacted Systems –Strong atomicity –Requester stalls –e.g LogTM, OneTM Cause –Two-level locking –No knowledge of lock dependency Effect –TM system stalls locks' logical owner T1 T2 Lock(L)‏ Spinning Stalling Non-TX TX Unlock(L)‏ NACK time

9 Livelock Impacted Systems –Strong atomicity –Requester wins –e.g Bulk, LTM Cause –Two-level locking –No knowledge of lock dependency Effect –TM system aborts locks' logical owner T1 T2 Lock(L)‏ Spinning Non-TX TX Unlock(L)‏ Abort Unlock(L)‏ Abort

10 Early Release Impacted Systems –Weak atomicity –Eager version management –e.g McRT-STM Cause –Restore values without lock held Effect –Lose lock-based mutual exclusion T1 T2 Lock(L)‏ Spinning Non-TX TX Unlock(L)‏ Abort Restore

11 Summary

12 Outline Pathologies Transaction-Safe Lock (TxLock)‏ Conclusion

13 TxLock Design Goals –Execute lock-based critical section code safely –Low overhead in non-transactional path Design elements –Non-transactional lock operations –Deferred Unlock –Lock-aware Conflict Resolution

14 Testing & Acquiring a lock Escape when Testing & Acquiring –Prevents transactional conflicts –Allows to observe most recent lock value After Acquiring –Compensate action to explicitly restore lock value on abort

15 When waiting on a lock? When waiting –Inform Contention Manager about dependency

16 When releasing a lock? Coordinate release –TM system: Releases transactional locks at commit –TxLocks: Commit action to release logical-lock at commit

17 Implementation LogTM-SE –Wisconsin GEMS OpenSolaris C Library –POSIX adaptive mutex locks –80 lines Contention Manager and Policy –990 lines

18 Preliminary Results Experience –Able to resolve deadlocks in libc malloc()‏ Quantitative –Development of workloads in progress –No rigorous performance evaluation –Overhead Low overhead Higher overhead

19 Summary Problem –Legacy code uses locks –Interaction of locks with transactional memory Interaction Pathologies –Identified five pathologies –Affect a spectrum of TM systems Transaction-safe Lock (TxLock)‏ –Execute lock-based critical sections inside transactions –Modified OpenSolaris libC

20 Questions ?

21 Backup Slides TxLocks vs SpinLocks Rest of Pathologies –Blocking –Invisible Locking Implementation Details – lock Implementation Details – unlock Design Elements

22 Blocking Cause –No support to abort while sleeping Effect –Cannot abort blocked transaction safely T1 T2 Lock(L)‏ Abort Non-TX TX Blocking

23 Blocking Cause –No support to abort while sleeping Effect –Cannot abort blocked transaction safely –Blocking degenerates into spinning Example Systems –LogTM –Bulk T1 T2 Lock(L)‏ Abort Lock(L)‏ Abort Lock(L)‏ Abort Spinning Non-TX TX

24 Invisible Locking Cause –Weak atomicity –Lazy Version Management Effect –Lose lock-based mutual exclusion Example System –TL2 T1 T2 Lock(L)‏ Non-TX TX No Mutual Exclusion

25 TxLocks vs cxspinlocks Programming interface –cxspinlocks: program using locks –TxLocks: program using transactions Optimistic concurrency –cxspinlocks: execute critical sections with optimistic concurrency –TxLocks: execute critical sections w/o optimistic concurrency Overhead –cxspinlocks: lock always introduces extra coherence traffic –TxLocks: pay extra cost when you acquire locks Hardware support –cxspinlocks: require special hardware: xcas and xtest –TxLocks: no special hardware; applicable to both HTM & STM

26 Implementation Details - lock 1. void lock(txlock_t* mp) { 2. ➊  BEGIN_ESCAPE; 3. if (set_lock_byte(&mp->txlock_lockw) == 0) { 4. mp->mutex_owner = (uintptr_t)self; 5. goto lock_acquired; 6. } 7. if (mp->mutex_owner == self) { 8. mp->rcount++; 9. goto lock_acquired_noTS; 10. } 11. if (txlock_trylock_adaptive(mp) != 0) { 12. if (txlock_lock_queue(self, mp) == ABORT) { 13. ➊ END_ESCAPE; 14. ABORT_TRANSACTION 15. } 16. } 17. lock_acquired: 18.  mp->timestamp = xact_timestamp(); 19. lock_acquired_noTS: 20. if (in_xact()) { 21. ➊ register_compensating_action( 22. ➊ txlock_unlock_impl, mp); 23. } 24. ➊ END_ESCAPE; 25. }

27 Implementation Details - unlock 26. void unlock(txlock_t* mp) { 27. BEGIN_ESCAPE; 28. if (mp->mutex_owner == self) { 29. mp->rcount++; 30. END_ESCAPE; 31. return; 32. } 33. if (in_xact()) { 34. register_commit_action( 35. txlock_unlock_impl, mp); 36. } else { 37. txlock_unlock_impl(mp); 38. } 39. END_ESCAPE; 40. }

28 1. Non-transactional Lock Operations Prevents –Invisible Locking –Livelock –Some Deadlock cases Method –Escape transactional control of lock code –Restore lock value through compensating action

29 2. Deferred Unlock Prevents –Early Release Method –Do not release lock in place but at commit –Recursive locking to avoid deadlock with itself

30 3. Lock-aware Conflict Resolution Prevents –Deadlock –Livelock Contention Manager –Is provided with transactional and lock dependencies –Builds full dependence graph –Finds correct victim transaction

31 4. Block/Wake-up Protocols Prevents –Blocking Protocols –Locks and contention manager cooperate to wake-up a blocked transaction –Use Abort/Block protocol when CANNOT suspend a TX –Use Block/Abort protocol when CAN suspend a TX