kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: kristof@sigsegv.be (Kristof Provost)
To: kernelnewbies@lists.kernelnewbies.org
Subject: freeing locks acquired by kernel thread?
Date: Wed, 4 Apr 2012 22:16:01 +0200	[thread overview]
Message-ID: <20120404201601.GP9275@thebe.jupiter.sigsegv.be> (raw)
In-Reply-To: <CAFTXMEJ6gfY9ZLDjwugMKo09eLomOQ0MuQhY3zJzo7aJz_YFTg@mail.gmail.com>

On 2012-04-04 10:50:23 (-0500), Asim <linkasim@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

      reply	other threads:[~2012-04-04 20:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-04 15:50 freeing locks acquired by kernel thread? Asim
2012-04-04 20:16 ` Kristof Provost [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120404201601.GP9275@thebe.jupiter.sigsegv.be \
    --to=kristof@sigsegv.be \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).