public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joshua MacDonald <jmacd@namesys.com>
To: Oliver Xymoron <oxymoron@waste.org>
Cc: Jesse Barnes <jbarnes@sgi.com>,
	Rik van Riel <riel@conectiva.com.br>,
	linux-kernel@vger.kernel.org, phillips@arcor.de, rml@tech9.net
Subject: Re: [PATCH] lock assertion macros for 2.5.30
Date: Thu, 8 Aug 2002 16:55:05 +0400	[thread overview]
Message-ID: <20020808125505.GA8804@reload.namesys.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0208071618290.16458-100000@waste.org>

MUST_NOT_HOLD_LOCK means exactly I_AM_NOT_HOLDING_LOCK, otherwise the
assertion is obviously meaningless because another processor could be holding
the lock.  But since there is no reason to assert NO_ONE_IS_HOLDING_LOCK
(since it means the lock is unnecessary), the obvious meaning of
MUST_NOT_HOLD_LOCK is the correct one, that the current thread/CPU does not
hold the lock.

In order to implement MOST_NOT_HOLD_LOCK the spinlock must contain some record
of who holds the lock, and since the SCSI-layer apparently does not have such
a mechanism, it appears that something is broken in there.

-josh



On Wed, Aug 07, 2002 at 04:37:40PM -0500, Oliver Xymoron wrote:
> On Wed, 7 Aug 2002, Jesse Barnes wrote:
> 
> > On Wed, Aug 07, 2002 at 06:02:19PM -0300, Rik van Riel wrote:
> > > On Wed, 7 Aug 2002, Jesse Barnes wrote:
> > >
> > > > +++ linux-2.5.30-lockassert/drivers/scsi/scsi.c Wed Aug  7 11:35:32 2002
> > > > @@ -262,7 +262,7 @@
> > >
> > > > +        MUST_NOT_HOLD(q->queue_lock);
> > >
> > > ...
> > >
> > > > +#if defined(CONFIG_DEBUG_SPINLOCK) && defined(CONFIG_SMP)
> > > > +#define MUST_HOLD(lock)			BUG_ON(!spin_is_locked(lock))
> > > > +#define MUST_NOT_HOLD(lock)		BUG_ON(spin_is_locked(lock))
> > >
> > > Please tell me the MUST_NOT_HOLD thing is a joke.
> > >
> > > What is to prevent another CPU in another code path
> > > from holding this spinlock when the code you've
> > > inserted the MUST_NOT_HOLD in is on its merry way
> > > not holding the lock ?
> >
> > Nothing at all, but isn't that how the scsi ASSERT_LOCK(&lock, 0)
> > macro worked before?  I could just remove all those checks in the scsi
> > code I guess.
> 
> Who's to say that they actually worked? They look like crap to me.
> 
> > After I posted the last patch, a few people asked for MUST_NOT_HOLD so
> > I added it back in.  Do you think it's a bad idea?  See the last
> > thread if you're curious (Joshua's comments in particular):
> > http://marc.theaimsgroup.com/?t=102764009400001&r=1&w=2
> 
> Interesting. I'm still going to say that MUST_NOT_HOLD is wrong, at least
> in its current form/name.
> 
> What MUST_HOLD is saying is "the current thread is holding this lock, go
> ahead, double check if you want". What MUST_NOT_HOLD says is "the current
> thread is not holding this lock, feel free to check". Right now the kernel
> doesn't record who grabbed a lock and the best it can do is check whether
> _anyone_ is holding the lock. In the first case, it can prove a negative
> if no one is holding the lock, in the second case it can't because it
> can't distiguish between the current task holding a lock and any other
> task holding a lock.
> 
> If we want a MUST_NOT_RECURSE, we can do that, but it means adding cpu or
> current into the debugging version of spinlocks. I'd also add eip, so we
> can see where the lock was acquired last and dump that when we hit a
> conflict/deadlock.
> 
> And if you interpret MUST_NOT_HOLD_LOCK to mean "no one is holding this
> lock" then you run into Rik's problem. Anyone who actually means this
> ought to be simply taking the lock, otherwise why would they care?
> 
> -- 
>  "Love the dolphins," she advised him. "Write by W.A.S.T.E.."
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
> 

  reply	other threads:[~2002-08-08 12:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-07 20:51 [PATCH] lock assertion macros for 2.5.30 Jesse Barnes
2002-08-07 21:02 ` Rik van Riel
2002-08-07 21:08   ` Jesse Barnes
2002-08-07 21:21     ` Rik van Riel
2002-08-07 21:39       ` Jesse Barnes
2002-08-07 21:44         ` Rik van Riel
2002-08-08  7:58         ` Marcin Dalecki
2002-08-08 11:09           ` Daniel Phillips
2002-08-07 22:15       ` Jesse Barnes
2002-08-07 22:19         ` Rik van Riel
2002-08-08 17:23           ` Jesse Barnes
2002-08-08 17:36             ` Rik van Riel
2002-08-08 17:39               ` Jesse Barnes
2002-08-09  2:56                 ` Daniel Phillips
2002-08-12 21:03                   ` [PATCH] lock assertion macros for 2.5.31 Jesse Barnes
     [not found]                     ` <3D5829B9.D281B855@zip.com.au>
     [not found]                       ` <20020812223645.GB40343@sgi.com>
     [not found]                         ` <3D5840E9.89C8680C@zip.com.au>
2002-08-21 18:26                           ` Jesse Barnes
2002-08-21 18:40                             ` Andrew Morton
2002-08-21 18:46                               ` Jesse Barnes
2002-08-09  3:04             ` [PATCH] lock assertion macros for 2.5.30 Daniel Phillips
2002-08-09  4:12               ` Bernd Eckenfels
2002-08-07 22:30         ` Daniel Phillips
2002-08-07 22:41           ` Roman Zippel
2002-08-08  0:07           ` Thunder from the hill
2002-08-07 21:37     ` Oliver Xymoron
2002-08-08 12:55       ` Joshua MacDonald [this message]
2002-08-08 13:23         ` Jens Axboe
2002-08-08  6:00     ` Jens Axboe
2002-08-08 17:08       ` Jesse Barnes
2002-08-08 17:31         ` Rik van Riel
2002-08-08 17:35           ` Jesse Barnes
2002-08-08 17:43           ` Joshua MacDonald
2002-08-08 17:47             ` Rik van Riel
     [not found] <0C01A29FBAE24448A792F5C68F5EA47D2D4437@nasdaq.ms.ensim.com>
2002-08-08 18:52 ` Paul Menage
2002-08-08 19:00   ` Rik van Riel

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=20020808125505.GA8804@reload.namesys.com \
    --to=jmacd@namesys.com \
    --cc=jbarnes@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oxymoron@waste.org \
    --cc=phillips@arcor.de \
    --cc=riel@conectiva.com.br \
    --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