Linux Kernel Spinlock Metering patch facilitates building i386, ia64, Alpha, Sparc64, or mips64 kernels with improved spinlock profiling.
Furthermore, this patch provides an added benefit of an associated new command known as lockstat. lockstat is responsible for turning the lock metering on or off and retrieving the relevant data from the kernel while displaying it in a human-readable format. The displayed data includes the number of lock attempts, per-spinlock per-caller, the number of immediate successful attempts versus those that required waiting, the mean and max hold-time, and the mean, max, and cumulative wait-time.
Moreover, the locking caller and spinlocks are identified by symbolic names, rather than virtual addresses. Various versions of the patch are available, including version 1.1.4 for 2.2.14 kernels, 1.4.11 for 2.4.16, 2.4.17, 2.5.3, and 2.5.5 kernels, and 1.4.9 for various other releases of the 2.4.x kernel.
Version 1.4 supports i386, alpha, ia64, mips64, and sparc64, while the latest version 1.5 is available as a patch against the 2.4.18 and various 2.5.x kernels, and it additionally supports mips (32-bit mips). After applying the appropriate patch, make oldconfig presents a new Kernel lock metering option in the Kernel hacking subsection.
However, this option is only visible if Symmetric multi-processing support (CONFIG_SMP) has been enabled. The spinlock metering code is compiled into the kernel only when the new option is turned on. The size of the kernel code is scarcely affected by this additional code since the normally in-line locking routines become procedure calls.
In terms of performance, a metering-enabled kernel is not significantly slower than a non-metering kernel. However, the lockstat command may cause a slowdown of approximately 8% for a systime workload when metering data collection is turned on.
Ultimately, the lockstat command requires root access and reads and writes to the node/proc/lockmeter to enable or disable kernel data collection. Through data collection, the lockstat command can accumulate and sort the per-cpu data to expose both "cause" and "effect" information about spinlock usage. The hold time metering shows which spinlocks are being held and for how long, while the wait-time metering exposes the effects of these hold-times when multiple CPUs compete for the same lock.
Version 1.4.11: N/A