You need to get a kernel with version 2.6.21 or higher (and no patching is necessary). Then, when configuring the kernel, you enable
CONFIG_TIMER_STATS (which is under the “
Kernel hacking” section, and a sub-option of
CONFIG_DEBUG_KERNEL). Also, you don’t want to run this kernel as your everyday kernel (since there is significant overhead with
CONFIG_TIMER_STATS).
If you don’t feel like compiling a special debug kernel, you might instead try a
precompiled one.