Browse Prior Art Database

Efficient sample-based kernel lock profiler Disclosure Number: IPCOM000015272D
Original Publication Date: 2002-Mar-08
Included in the Prior Art Database: 2003-Jun-20

Publishing Venue



Efficient kernel lock routines are critical for SMP OS's due to the frequency with which these routines are used to control access to critical data structures in an MP environment. These routines and the individual locks they operate on can quickly become a major bottleneck and degrade OS performance. Methods to monitor these routines typically include inclusion of trace hooks or other instrumentation code inserted into these routines in order to facilitate monitoring their behavior. However, do to the rate at which these lock routines are typically called, a few lines of instrumentation code added to these routines can degrade system performance by as much as 20% or more and in fact alter the behavior of the machine due to timing differences imposed by the instrumented lock routines. This disclosure presents an implementation of a sample-based lock hit/miss analyzer which only requires the addition of two instructions to the lock routine. A per-processor data area is pre-allocated to contain the most recent lock address and calling routine for both lock hits and misses. Two store instructions are added to the beginning of the lock routine to store the lock address and calling routine to the per-cpu lock hit array (or lock miss array if the lock is currently busy). A user level utility wakes up periodically (and randomly) and reads/clears the previous lock hit/miss lock address and caller and buffers these "samples". Over time with random sampling, a histogram of lock hits/misses per lock and per lock routine caller is collected which indicates which locks are being used the most and which locks are being missed the most. Used in conjunction with a low overhead, sample-based system profiler that indicates how often the lock routines are called, one can infer how critical these lock hit/miss percentages are relative to other system behavior, therefore isolating/identifying hot locks without imposing significant performance degradation to the operating system. 1