Debugging Linux Kernel using ftrace Part 19 - Finding Maximum Kernel Stack Size

Kernel has a fixed stack size. The default stack size for process running in kernel is 8K. Call a function in recursion without any break, you will observe system will freeze within seconds. A kernel developer should be careful with what they are allocating on the stack. If he adds a lot to the kernel stack, stack overflow can happen and finally system panic.

To enable the stack tracing functionality,

echo 1 > /proc/sys/kernel/stack_tracer_enabled

Wait for few minutes to get a better information.

Files to look to get stack information:

/sys/kernel/tracing/stack_max_size: Displays the maximum size it has encountered
/sys/kernel/tracing/stack_trace: Displays the backtrace of the largest stack trace encountered after activating stack tracer
/sys/kernel/tracing/stack_trace_filter: Limits what functions stack tracer will check, it is similar to "set_ftrace_filter"



Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig