alexgolec
alexgolec

Reputation: 28252

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

I am writing 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.

Upvotes: 2

Views: 1141

Answers (2)

Tan En De
Tan En De

Reputation: 361

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


Upvotes: 0

mpe
mpe

Reputation: 2730

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.

Upvotes: 3

Related Questions