linux/arch/x86
Steven Rostedt 3d0833953e ftrace: dynamic enabling/disabling of function calls
This patch adds a feature to dynamically replace the ftrace code
with the jmps to allow a kernel with ftrace configured to run
as fast as it can without it configured.

The way this works, is on bootup (if ftrace is enabled), a ftrace
function is registered to record the instruction pointer of all
places that call the function.

Later, if there's still any code to patch, a kthread is awoken
(rate limited to at most once a second) that performs a stop_machine,
and replaces all the code that was called with a jmp over the call
to ftrace. It only replaces what was found the previous time. Typically
the system reaches equilibrium quickly after bootup and there's no code
patching needed at all.

e.g.

  call ftrace  /* 5 bytes */

is replaced with

  jmp 3f  /* jmp is 2 bytes and we jump 3 forward */
3:

When we want to enable ftrace for function tracing, the IP recording
is removed, and stop_machine is called again to replace all the locations
of that were recorded back to the call of ftrace.  When it is disabled,
we replace the code back to the jmp.

Allocation is done by the kthread. If the ftrace recording function is
called, and we don't have any record slots available, then we simply
skip that call. Once a second a new page (if needed) is allocated for
recording new ftrace function calls.  A large batch is allocated at
boot up to get most of the calls there.

Because we do this via stop_machine, we don't have to worry about another
CPU executing a ftrace call as we modify it. But we do need to worry
about NMI's so all functions that might be called via nmi must be
annotated with notrace_nmi. When this code is configured in, the NMI code
will not call notrace.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-23 20:33:09 +02:00
..
boot
configs
crypto
ia32
kernel ftrace: dynamic enabling/disabling of function calls 2008-05-23 20:33:09 +02:00
kvm KVM: LAPIC: ignore pending timers if LVTT is disabled 2008-05-18 14:39:39 +03:00
lguest
lib ftrace: trace irq disabled critical timings 2008-05-23 20:32:46 +02:00
mach-default
mach-es7000
mach-generic
mach-rdc321x
mach-visws
mach-voyager
math-emu
mm x86: fix crash on cpu hotplug on pat-incapable machines 2008-05-17 22:57:20 +02:00
oprofile
pci PCI: Correct last two HP entries in the bfsort whitelist 2008-05-19 12:21:36 -07:00
power
vdso x86: add notrace annotations to vsyscall. 2008-05-23 20:31:39 +02:00
video x86: video/fbdev.c: add MODULE_LICENSE 2008-05-04 20:04:46 +02:00
xen
Kconfig ftrace: add basic support for gcc profiler instrumentation 2008-05-23 20:31:58 +02:00
Kconfig.cpu
Kconfig.debug
Makefile
Makefile_32.cpu