From: Joshua MacDonald <jmacd@namesys.com>
To: linux-kernel@vger.kernel.org
Cc: oxymoron@waste.com, jbarnes@sgi.com, reiser@namesys.com
Subject: Re: [PATCH] lock assertion macros for 2.5.28
Date: Fri, 2 Aug 2002 19:17:58 +0400 [thread overview]
Message-ID: <20020802151758.GD5469@reload.namesys.com> (raw)
In-Reply-To: <20020726174258.GC793866@sgi.com>
On Fri, Jul 26, 2002 at 10:42:58AM -0700, Jesse Barnes wrote:
> On Fri, Jul 26, 2002 at 04:09:18PM +0400, Joshua MacDonald wrote:
> > In reiser4 we are looking forward to having a MUST_NOT_HOLD (i.e.,
> > spin_is_not_locked) assertion for kernel spinlocks. Do you know if any
> > progress has been made in that direction?
>
> Well, I had that in one version of the patch, but people didn't think
> it would be useful. Maybe you'd like to check out Oliver's comments
> at http://marc.theaimsgroup.com/?l=linux-kernel&m=102644431806734&w=2
> and respond? If there's demand for MUST_NOT_HOLD, I'd be happy to add
> it since it should be easy. But if you're using it to enforce lock
> ordering as Oliver suggests, then there are probably more robust
> solutions.
>
I read Oliver's comments and I do not fully agree. It is true that often the
MUST_NOT_HOLD macro is used to assert that you are not about to attempt a
recursive lock, which a debugging spinlock implementation would catch as soon
as the recursive attempt is made. However, it is difficult to make a case
against adding support for this kind of assertion since it has many possible
uses.
It may be useful to catch a recursive spinlock attempt several stack frames
before it actually happens, or to assert that an unusual calling convention
such as "This function is called with the spinlock held and if it returns 0
the spinlock remains held, but if the function returns non-zero the spinlock
is released". We have such a function in reiser4.
As for preventing deadlock, it is true that (as Oliver says) "Locking order is
larger than functions and should be documented at the point of declaration of
the locks." We have a mechanism in reiser4 which is not quite the same as
Oliver outlined for making assertions about lock ordering. We maintain
per-thread counts of each spinlock class and use those counts in a locking
predicate that is applied before a lock of each class is taken.
So I agree that recursive locking should be checked as part of the debugging
spin_lock() routine and that deadlock detection requires more general work,
but the MUST_NOT_HOLD assertion is still useful in some contexts.
-josh
prev parent reply other threads:[~2002-08-02 15:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-25 23:30 [PATCH] lock assertion macros for 2.5.28 Jesse Barnes
2002-07-26 5:11 ` Marcin Dalecki
2002-07-26 17:40 ` Jesse Barnes
2002-07-27 13:59 ` Daniel Phillips
2002-07-26 12:09 ` Joshua MacDonald
2002-07-26 17:42 ` Jesse Barnes
2002-07-26 17:54 ` Christoph Hellwig
2002-07-26 18:05 ` Jesse Barnes
2002-07-27 13:56 ` Daniel Phillips
2002-07-26 19:38 ` Robert Love
2002-08-02 15:17 ` Joshua MacDonald [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=20020802151758.GD5469@reload.namesys.com \
--to=jmacd@namesys.com \
--cc=jbarnes@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oxymoron@waste.com \
--cc=reiser@namesys.com \
/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