enable/disable function tracing dynamically

modulename: mcount-dyn.ko

and/or

ftrace.ko

configname: CONFIG_DYNAMIC_FTRACE

Linux Kernel Configuration
└─>Tracers
└─>enable/disable function tracing dynamically
In linux kernel since version 2.6.27 (release Date: 2008-10-09)  
This option will modify all the calls to function tracing
dynamically (will patch them out of the binary image and
replace them with a No-Op instruction) on boot up. During
compile time, a table is made of all the locations that ftrace
can function trace, and this table is linked into the kernel
image. When this is enabled, functions can be individually
enabled, and the functions not enabled will not affect
performance of the system.

See the files in /sys/kernel/debug/tracing:
available_filter_functions
set_ftrace_filter
set_ftrace_notrace

This way a CONFIG_FUNCTION_TRACER kernel is slightly larger, but
otherwise has native performance as long as no tracing is active.

source code: