130 likes | 210 Views
Synchronization Aware Conflict Resolution for Runtime Monitoring using Transactional Memory. Chen Tian, Vijay Nagarajan, Rajiv Gupta April 6, 2008. load A, R1. Mem. store ins Meta-data for A. Shadow Mem. store R2, B. store ins Meta-data for B. Actual instruction sequence.
E N D
Synchronization Aware Conflict Resolution for Runtime Monitoring using Transactional Memory Chen Tian, Vijay Nagarajan, Rajiv Gupta April 6, 2008
load A, R1 Mem. storeinsMeta-data for A Shadow Mem. store R2, B storeinsMeta-data for B Actual instruction sequence Runtime Monitoring • Useful in many places • debugging, profiling, security • Dynamic binary translation tools -DBT • Example: Pin, Valgrind • Main task: instrumentation
start_tranx start_tranx Core 2 end_tranx end_tranx load2 … Monitoring on Multicore Machine • Race problem Core 1 load1 … loadins r1, X incins r1, 1 loadins r2, X incins r2, 1 storeins r1 , X storeins r2 , X Conflict! Wrong ! • Solution ? • Transactional memory - TM (J. Chung et al. HPCA’ 08) • Transaction size • new instruction overhead VS abort overhead
Overhead and Transaction Size • Creating a transaction per basic block • worst performance (over 60%) • Larger transaction is preferred • Trace granularity and dynamic merging
More about TM system • Hardware and Software • This work focus on hardware - HTM • 3 key functions: • Memory version management • Conflict detection • cache coherence message (HTM) • Conflict resolution • 3 existing HTM designs • EE – eager detection, requester loses • EL – eager detection, requester wins • LL – lazy detection, committer wins
start_tranx start_tranx EE Policy: Requester loses Abort! … while (flag1 != 1) ; flag2 = 1; … … flag1 = 1; while (flag2 != 1) ; … … while (flag != 1) ; … … flag = 1; … end_tranx end_tranx Live Lock Problem • Example Core 1 Core 2 • Reason • DBT tools put the sync. into transactions • Especially for busy-waiting sync. • HTM doesn’t know the conflict is caused by sync. • Fix it by making HTM sync.-aware
Remote Write Now you can go! No ! Yes ! Spinning Read Can I go? Busy-waiting Synchronization Pattern • Spinning read and a remote write • Flag sync., locks, barriers Spinning read: a load repeated X times Remote write: value changed by another thread
Hardware Implementation • Load table, Detector, Synchronization Table • Simulated on Simics
New Conflict Resolution • Key idea: A transaction which performs the sync. write should be committed immediately! • Add two rules • When a sync. pattern is detected, notify the HTM (avoid or break live locks due to sync.) • When a conflict is detected, check the syn_table (ensure discovered sync. will not cause live locks )
start_tranx start_tranx … flag = 1; … flag = 1; … Synchronization Detected! end_tranx end_tranx ... start_tranx … end_tranx Example • When T1 comes again, it will see the updated value of flag. Transaction 1 Transaction 2 start_tranx … while (flag != 1) ; … Abort! end_tranx
Comparison with Time-out • Time-out solution • Periodically check the progress • Re-instrumentation on the fly • Pay extra overhead • (conflict may only happen once) • Our solution (relies on HTM, not DBT) • No need for re-instrumentation • Only need to check when there is conflict
Thanks ! • Any Questions?