All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jerry Cooperstein <jerry.cooperstein@charter.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: mutex_unlock() in interrupt context
Date: Tue, 17 Jul 2007 00:01:38 -0700	[thread overview]
Message-ID: <20070717000138.0d255ed5.akpm@linux-foundation.org> (raw)
In-Reply-To: <46981580.5000008@charter.net>

On Fri, 13 Jul 2007 19:14:56 -0500 Jerry Cooperstein <jerry.cooperstein@charter.net> wrote:

> kernel/mutex.c says about mutex_unlock():
> 
>   * This function must not be used in interrupt context.
> 
> However I have done some simple test cases that show
> it works without complaint.  Now I understand that one
> shouldn't do this for good reasons.  So is this a
> good coding practice rule, but something that
> could appear in sloppy or poorly designed code?
> 

mutex_unlock() must be called by the process which did the mutex_lock(). 
Doing the mutex_unlock() from an interrupt will cause warnings when run
with debugging enabled.  You should run with debugging enabled when doing
any development.  

Also, mutex_unlock() takes a mutex-internal spinlock in a non-irq-safe
fashion - if the timing is right, your mutex_unlock() in IRQ context will
deadlock.


      reply	other threads:[~2007-07-17  7:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-13 22:35 [-mm PATCH 0/2] 74% decrease in dispatched writes, stripe-queue take3 Dan Williams
2007-07-13 22:35 ` [-mm PATCH 1/2] raid5: add the stripe_queue object for tracking raid io requests (take2) Dan Williams
2007-07-13 22:35 ` [-mm PATCH 2/2] raid5: use stripe_queues to prioritize the "most deserving" requests (take3) Dan Williams
2007-07-13 22:54 ` [-mm PATCH 0/2] 74% decrease in dispatched writes, stripe-queue take3 Andrew Morton
2007-07-13 22:57   ` Williams, Dan J
2007-07-13 22:57     ` Williams, Dan J
2007-07-13 23:01     ` Andrew Morton
2007-07-13 23:01       ` Andrew Morton
2007-07-13 23:28       ` Williams, Dan J
2007-07-13 23:28         ` Williams, Dan J
2007-07-14  0:01         ` Andrew Morton
2007-07-14  0:01           ` Andrew Morton
2007-07-14  0:14           ` mutex_unlock() in interrupt context Jerry Cooperstein
2007-07-17  7:01             ` Andrew Morton [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=20070717000138.0d255ed5.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=jerry.cooperstein@charter.net \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.