Linux Kernel 當前運行中 鎖的狀態信息【適用於調試模式】。
俺的設備死機的時候,發現是因為鎖導致的,這時候相當郁悶的是沒地方看系統相關鎖的信息,當找到內核文檔下的相關信息後,
大驚:原來開發者已經為俺考慮好這些東東了:進入調試模式就是這麼簡單:
鎖統計信息信息
LOCK STATISTICS
- WHY
鎖競爭會嚴重地影響性能和表現
Because things like lock contention can severely impact performance.
- HOW
如何實現
Lockdep already has hooks in the lock functions and maps lock instances to
lock classes. We build on that. The graph below shows the relation between
the lock functions and the various hooks therein.
__acquire
|
lock _____
| \
| __contended
| |
| <wait>
| _______/
|/
|
__acquired
|
.
<hold>
.
|
__release
|
unlock
lock, unlock - the regular lock functions
__* - the hooks
<> - states
With these hooks we provide the following statistics:
con-bounces - number of lock contention that involved x-cpu data
contentions - number of lock acquisitions that had to wait
wait time min - shortest (non-0) time we ever had to wait for a lock
max - longest time we ever had to wait for a lock
total - total time we spend waiting on this lock
acq-bounces - number of lock acquisitions that involved x-cpu data
acquisitions - number of times we took the lock
hold time min - shortest (non-0) time we ever held the lock
max - longest time we ever held the lock
total - total time this lock was held
From these number various other statistics can be derived, such as:
hold time average = hold time total / acquisitions
These numbers are gathered per lock class, per read/write state (when
applicable).
It also tracks 4 contention points per class. A contention point is a call site
that had to wait on lock acquisition.
- USAGE
Look at the current lock statistics:
( line numbers not part of actual output, done for clarity in the explanation
below )
# less /proc/lock_stat