freeing locks acquired by kernel thread?
Kristof Provost
kristof at sigsegv.be
Wed Apr 4 16:16:01 EDT 2012
On 2012-04-04 10:50:23 (-0500), Asim <linkasim at gmail.com> wrote:
> Hi,
>
> I have a driver thread that I kill using do_exit(SIGKILL) upon
> exception. Unfortunately, I do not see it releasing all locks when it
> exits and I get a lockdep trace. The exit_sem() code does not seem to
> free my mutexes.
>
> If anyone has had success in clearing all locks of a thread upon exit,
> or has a pointer to such an existing code in kernel it would be
> useful.
>
"Don't do that!"
You're not programming in user space. The kernel won't clean up after you.
Manage your locks yourself, don't just kill threads and expect
everything to work!
You need to signal your thread to stop and let it clean up everything
before it exists.
More abstractly: you have mutexes which implies you have shared data
structures between the thread you want to kill and some other code.
How could you ensure the data is in a consistent state if the thread can
be killed at any point?
Regards,
Kristof
More information about the Kernelnewbies
mailing list