linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Robert Love <rml@tech9.net>
Cc: John Levon <movement@marcelothewonderpenguin.com>,
	linux-kernel@vger.kernel.org, akpm@digeo.com
Subject: Re: Sleeping function called from illegal context...
Date: Sat, 28 Sep 2002 17:50:19 -0700	[thread overview]
Message-ID: <20020929005019.GD22942@holomorphy.com> (raw)
In-Reply-To: <1033237664.22582.167.camel@phantasy>

On Sat, 2002-09-28 at 13:24, John Levon wrote:
>> NMI interrupt handler cannot block so it trylocks against a spinlock
>> instead. Buffer processing code needs to block against concurrent NMI
>> interrupts so takes the spinlock for them. All actual blocks on the
>> spinlock are beneath a down() on another semaphore, so a sleep whilst
>> holding the spinlock won't actually cause deadlock.

On Sat, Sep 28, 2002 at 02:27:44PM -0400, Robert Love wrote:
> If all accesses to the spinlock are taken under a semaphore, then the
> spinlock is not needed (i.e. the down'ed semaphore provides the same
> protection), or am I missing something?
> If this is not the case - e.g. there are other accesses to these locks -
> then you cannot sleep, no?
> I really can think of no case in which it is safe to sleep while holding
> a spinlock or otherwise atomic.  If it is, then the atomicity is not
> needed, sort of by definition.

Actually, though he may be using a spinlock_t, when used this way, it
is not a spinlock, but rather a semaphore-like construct like PG_locked.
Spinlocks include blocking via busywait semantics, which this usage
does not have. It just happens to use the same data type. There are
other interesting abuses of spinlock-like constructs in "advanced"
locks, for instance, in non-sleeping handoff-scheduled queueing locks
(e.g. MCS spinlocks and rwlocks) it's a common idiom for one waiter to
set a "blocked" bit or lock word and then spin on it until another
waiter and/or cpu manipulating the lock clears it.


Bill

      parent reply	other threads:[~2002-09-29  0:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-27 23:30 Sleeping function called from illegal context Greg KH
2002-09-27 23:50 ` Andrew Morton
2002-09-28  0:43   ` (more) " Luc Van Oostenryck
2002-09-28  1:22     ` Andrew Morton
2002-09-28  0:44   ` Luc Van Oostenryck
2002-09-28  1:24     ` Andrew Morton
2002-09-28  2:15       ` Greg KH
2002-09-28  0:44   ` Luc Van Oostenryck
2002-09-28  1:27     ` Andrew Morton
2002-09-30 12:50       ` [Lksctp-developers] " Jon Grimm
2002-09-30 13:34       ` Jon Grimm
2002-09-28  2:04   ` Andre Hedrick
2002-09-28  3:06     ` Robert Love
2002-09-28  3:21       ` Andre Hedrick
2002-09-28  3:29         ` Robert Love
2002-09-28 10:06         ` Alan Cox
2002-09-28 17:06           ` Robert Love
2002-09-28  0:51 ` Robert Love
2002-09-28  2:16   ` Greg KH
2002-09-28 14:54   ` John Levon
2002-09-28 17:05     ` Andrew Morton
2002-09-28 17:24       ` John Levon
2002-09-28 18:27         ` Robert Love
2002-09-28 18:38           ` John Levon
2002-09-29  0:50           ` William Lee Irwin III [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=20020929005019.GD22942@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=movement@marcelothewonderpenguin.com \
    --cc=rml@tech9.net \
    /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).