开发者

Can I print out, on a kernel panic, what locks are held when the system crashed?

I am writi开发者_开发技巧ng an assignment (so I'm under lots of pressure, hehe) and I have a particular place where my project is dereferencing NULL.

The details are this: it's a system call that walks the page table entries of this process and reports which were accessed since the call last happened. Please do no give suggestions about the problem itself, as I don't want to violate any academic honesty rules.

It seems to be the case, however, that the execution of the system call is preempted, and something goes in and screws with the structures I'm using. The infuriating thing is that I can't figure out what.

Therefore, I want the panic to tell me what spinlocks/semaphores, etc. are being held at the time of the panic. This would give me a hint as to what the hell is going on.


If you build your kernel with CONFIG_LOCKDEP enabled you should be able to dump all locks with alt-sysrq-D. See drivers/tty/sysrq.c.


Method 1: Append kernel boot-time parameter

panic_print=0x08

Method 2: Equivalent kernel sysctl knob

echo 8 > /proc/sys/kernel/panic_print

Reference:

Documentation for /proc/sys/kernel

panic_print

Bitmask for printing system info when panic happens.
User can chose combination of the following bits:

===== ============================================
bit 0 print all tasks info
bit 1 print system memory info
bit 2 print timer info
bit 3 print locks info if CONFIG_LOCKDEP is on
bit 4 print ftrace buffer
bit 5 print all printk messages in buffer
bit 6 print all CPUs backtrace (if available in the arch)
===== ============================================

So for example to print tasks and memory info on panic, user can::

echo 3 > /proc/sys/kernel/panic_print


0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜