I have a linux kernel driver and a user app that interacts with it. The kernel driver has a deadlock in it. I came accross this feature in the linux kernel called "lockdep". I was able to configure it and recompile my kernel (and I do see the lockdep folders in /proc). But I don't know how to infer the output of this tool or how to go about debugging the driver using this tool for that matter. Any help will much appreciated. Thanks!
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
To enable lockdep feature, edit .config file through menuconfig:
And enable following in Hacking Options:
Recompile the kernel:
Now, boot the new kernel image, under /proc you should see the following new folders:
Now, insert the module you think that is causing the error, and access it with your user application (or whatever way you use to run your driver module). If the app deadlocks(hangs), do a:
you should see a +D (uninterruptible sleep) state for your app, do a:
The log it prints will include the function/file causing the deadlock.
That's it!
There is not much to it – the lockdep code will simply print a description of the situation and a stack backtrace to the kernel log when it encounters a locking sequence that potentially deadlocks. You just have to watch your kernel output (via
dmesg
or serial line or whatever you use).The lockdep code debugs only locks, it can not warn you about deadlocks that arise from something else.