linux/include
Peter Zijlstra f20786ff4d lockstat: core infrastructure
Introduce the core lock statistics code.

Lock statistics provides lock wait-time and hold-time (as well as the count
of corresponding contention and acquisitions events). Also, the first few
call-sites that encounter contention are tracked.

Lock wait-time is the time spent waiting on the lock. This provides insight
into the locking scheme, that is, a heavily contended lock is indicative of
a too coarse locking scheme.

Lock hold-time is the duration the lock was held, this provides a reference for
the wait-time numbers, so they can be put into perspective.

  1)
    lock
  2)
    ... do stuff ..
    unlock
  3)

The time between 1 and 2 is the wait-time. The time between 2 and 3 is the
hold-time.

The lockdep held-lock tracking code is reused, because it already collects locks
into meaningful groups (classes), and because it is an existing infrastructure
for lock instrumentation.

Currently lockdep tracks lock acquisition with two hooks:

  lock()
    lock_acquire()
    _lock()

 ... code protected by lock ...

  unlock()
    lock_release()
    _unlock()

We need to extend this with two more hooks, in order to measure contention.

  lock_contended() - used to measure contention events
  lock_acquired()  - completion of the contention

These are then placed the following way:

  lock()
    lock_acquire()
    if (!_try_lock())
      lock_contended()
      _lock()
      lock_acquired()

 ... do locked stuff ...

  unlock()
    lock_release()
    _unlock()

(Note: the try_lock() 'trick' is used to avoid instrumenting all platform
       dependent lock primitive implementations.)

It is also possible to toggle the two lockdep features at runtime using:

  /proc/sys/kernel/prove_locking
  /proc/sys/kernel/lock_stat

(esp. turning off the O(n^2) prove_locking functionaliy can help)

[akpm@linux-foundation.org: build fixes]
[akpm@linux-foundation.org: nuke unneeded ifdefs]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-19 10:04:49 -07:00
..
acpi Pull osi-now into release branch 2007-06-02 01:02:09 -04:00
asm-alpha arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-arm arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-arm26 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-avr32 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-blackfin fbdev: detect primary display device 2007-07-17 10:23:11 -07:00
asm-cris arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-frv arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-generic i386: Put allocated ELF notes in read-only data segment 2007-07-19 10:04:47 -07:00
asm-h8300 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-i386 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-ia64 coredump masking: reimplementation of dumpable using two flags 2007-07-19 10:04:46 -07:00
asm-m32r arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-m68k arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-m68knommu fbdev: detect primary display device 2007-07-17 10:23:11 -07:00
asm-mips arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-parisc arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-powerpc arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-ppc mm: remove ptep_test_and_clear_dirty and ptep_clear_flush_dirty 2007-07-17 10:22:59 -07:00
asm-s390 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-sh arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-sh64 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-sparc arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-sparc64 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-um arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-v850 fbdev: detect primary display device 2007-07-17 10:23:11 -07:00
asm-x86_64 arch: personality independent stack top 2007-07-19 10:04:45 -07:00
asm-xtensa arch: personality independent stack top 2007-07-19 10:04:45 -07:00
crypto [CRYPTO] cryptd: Add software async crypto daemon 2007-05-02 14:38:32 +10:00
keys [AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both 2007-04-26 15:48:28 -07:00
linux lockstat: core infrastructure 2007-07-19 10:04:49 -07:00
math-emu Delete unused header file math-emu/extended.h 2007-05-08 11:15:05 -07:00
media V4L/DVB (5835): saa7146/dvb-ttpci: Fix signedness warnings (gcc 4.1.1, kernel 2.6.22) 2007-07-18 14:24:44 -03:00
mtd UBI: kill homegrown endian macros 2007-07-18 16:53:49 +03:00
net [XFRM]: Fix crash introduced by struct dst_entry reordering 2007-07-18 01:55:52 -07:00
pcmcia PCMCIA-NETDEV : add new ID of lan&modem multifunction card 2007-07-08 22:16:39 -04:00
rdma IB/cm: Include HCA ACK delay in local ACK timeout 2007-07-10 21:50:05 -07:00
rxrpc [AF_RXRPC]: Delete the old RxRPC code. 2007-04-26 15:55:48 -07:00
scsi [SCSI] Remove unused method scsi_device_cancel 2007-07-14 16:01:16 -05:00
sound [ALSA] version 1.0.14 2007-05-31 11:03:27 +02:00
video tgafb: actually allocate memory for the pseudo_palette 2007-07-17 10:23:12 -07:00
xen xen: Place vcpu_info structure into per-cpu memory 2007-07-18 08:47:45 -07:00
Kbuild