linux-IllusionX/kernel
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
..
irq
power PM: Integrate beeping flag with existing acpi_sleep flags 2007-07-19 10:04:43 -07:00
time
.gitignore
acct.c
audit.c
audit.h
auditfilter.c
auditsc.c mm: variable length argument support 2007-07-19 10:04:45 -07:00
capability.c
compat.c
configs.c
cpu.c
cpuset.c
delayacct.c
die_notifier.c
dma.c
exec_domain.c
exit.c
extable.c
fork.c coredump masking: add an interface for core dump filter 2007-07-19 10:04:47 -07:00
futex.c
futex_compat.c
hrtimer.c
itimer.c
kallsyms.c
Kconfig.hz
Kconfig.preempt
kexec.c
kfifo.c
kmod.c PM: prevent frozen user mode helpers from failing the freezing of tasks 2007-07-19 10:04:42 -07:00
kprobes.c jprobes: make jprobes a little safer for users 2007-07-19 10:04:44 -07:00
ksysfs.c Add /sys/kernel/notes 2007-07-19 10:04:47 -07:00
kthread.c
latency.c
lockdep.c lockstat: core infrastructure 2007-07-19 10:04:49 -07:00
lockdep_internals.h
lockdep_proc.c lockdep: reduce the ifdeffery 2007-07-19 10:04:49 -07:00
Makefile
module.c
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
nsproxy.c
panic.c
params.c
pid.c
posix-cpu-timers.c
posix-timers.c
printk.c
profile.c
ptrace.c coredump masking: reimplementation of dumpable using two flags 2007-07-19 10:04:46 -07:00
rcupdate.c
rcutorture.c
relay.c kernel/relay.c: make functions static 2007-07-19 10:04:47 -07:00
resource.c
rtmutex-debug.c
rtmutex-debug.h
rtmutex-tester.c
rtmutex.c
rtmutex.h
rtmutex_common.h
rwsem.c
sched.c use the new percpu interface for shared data 2007-07-19 10:04:45 -07:00
sched_debug.c
sched_fair.c
sched_idletask.c
sched_rt.c
sched_stats.h
seccomp.c
signal.c
softirq.c
softlockup.c
spinlock.c lockdep: sanitise CONFIG_PROVE_LOCKING 2007-07-19 10:04:49 -07:00
srcu.c
stacktrace.c
stop_machine.c
sys.c coredump masking: reimplementation of dumpable using two flags 2007-07-19 10:04:46 -07:00
sys_ni.c
sysctl.c lockstat: core infrastructure 2007-07-19 10:04:49 -07:00
taskstats.c
time.c
timer.c
tsacct.c
uid16.c
user.c
user_namespace.c
utsname.c
utsname_sysctl.c
wait.c
workqueue.c