preemption logging - debugging tool that creates a buffer for recording
kernel preemption events.

Originally by Nigel Gamble.
Maintained by Robert Love.

CONFIG_PREEMPT_LOG adds a kernel preemption log, which can be very
useful in debugging unprotected critical regions.  The log records the
instruction address where the preemption occurred, the PID of the
process that was preempted, and a timestamp.

show_preempt_log() dumps the most recent 20 events, most recent first.
Printed for each event are the PID of the preempted process, the number
of milliseconds since the most recent preemption and the instruction
pointer address of where the process was preempted.  show_preempt_log()
is added to the kernel Oops message, and can also be viewed with
SysRq-W.  (The addresses are repeated in a format that can be fed to
ksymoops for decoding into symbols.)

save_preempt_log() can be used to take a snapshot of the preemption log
after an "interesting" event has taken place.  For example, I used this
to catch the preemption problem that turned out to be the page fault
trap handler being called with interrupts enabled, leading to corruption
of the fault address register if preemption occurred before it was
saved.  I added a call to save_preemp_log() in fault.c at the point
where a process is about to be killed with a SEGFAULT.  Sure enough, the
preemption log showed a preemption on the first instruction of the trap
handler whenever a process unexpectedly SEGVed.  (This problem was fixed
in Linux subsequently, when it turned out to be a problem even without
preemption.)