public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@sgi.com>
To: Daniel Phillips <phillips@arcor.de>
Cc: Arnd Bergmann <arnd@bergmann-dalldorf.de>,
	linux-kernel@vger.kernel.org,
	kernel-janitor-discuss@lists.sourceforge.net
Subject: [PATCH] spinlock assertion macros for 2.5.26
Date: Thu, 18 Jul 2002 16:36:13 -0700	[thread overview]
Message-ID: <20020718233613.GC763939@sgi.com> (raw)
In-Reply-To: <E17UiO0-0004Jn-00@starship>

On Wed, Jul 17, 2002 at 08:34:05AM +0200, Daniel Phillips wrote:
> You could create linux/semaphore.h which includes asm/semaphore.h, making
> the whole arrangement more similar to spinlocks.  That would be the manly
> thing to do, however, manliness not necessarily being the fashion at the
> moment, putting them in the arch-specific headers seems like the route of
> least resistance.  One day, a prince on a white horse will come along and
> clean up all the header files...

Well, I'll at least take a stab at it, but I won't have time until
next week.  Here's the current version of the macros against 2.5.26
though, in case someone wants to add support for architectures other
than ia64.

> > I thought Oliver's suggestion for tracking the order of spinlock
> > acquisition was good, hopefully someone will take a stab at it along
> > with Dave's FUNCTION_SLEEPS() implementation.

It doesn't look like it would be too hard to do, but seems like it
should be a seperate patch (maybe with more header file tweaking).

> On the minor niggle side, I think "MUST_HOLD" scans better than
> "MUST_HOLD_SPIN", since the former is closer to the way we say it when
> we're talking amongst ourselves.

Sure thing.  I fixed it up in this version.

Thanks,
Jesse

diff -Naur -X /home/jbarnes/dontdiff linux-2.5.26/fs/inode.c linux-2.5.26-lockassert/fs/inode.c
--- linux-2.5.26/fs/inode.c	Tue Jul 16 16:49:38 2002
+++ linux-2.5.26-lockassert/fs/inode.c	Thu Jul 18 10:21:13 2002
@@ -183,6 +183,8 @@
  */
 void __iget(struct inode * inode)
 {
+	MUST_HOLD(&inode_lock);
+
 	if (atomic_read(&inode->i_count)) {
 		atomic_inc(&inode->i_count);
 		return;
diff -Naur -X /home/jbarnes/dontdiff linux-2.5.26/include/asm-ia64/spinlock.h linux-2.5.26-lockassert/include/asm-ia64/spinlock.h
--- linux-2.5.26/include/asm-ia64/spinlock.h	Tue Jul 16 16:49:25 2002
+++ linux-2.5.26-lockassert/include/asm-ia64/spinlock.h	Thu Jul 18 16:30:49 2002
@@ -109,6 +109,7 @@
 #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
 
 #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
+#define rwlock_is_locked(x) ((x)->read_counter != 0 || (x)->write_lock != 0)
 
 #define _raw_read_lock(rw)							\
 do {										\
diff -Naur -X /home/jbarnes/dontdiff linux-2.5.26/include/linux/spinlock.h linux-2.5.26-lockassert/include/linux/spinlock.h
--- linux-2.5.26/include/linux/spinlock.h	Tue Jul 16 16:49:33 2002
+++ linux-2.5.26-lockassert/include/linux/spinlock.h	Thu Jul 18 16:31:13 2002
@@ -116,7 +116,19 @@
 #define _raw_write_lock(lock)	(void)(lock) /* Not "unused variable". */
 #define _raw_write_unlock(lock)	do { } while(0)
 
-#endif /* !SMP */
+#endif /* !CONFIG_SMP */
+
+/*
+ * Simple lock assertions for debugging and documenting where locks need
+ * to be locked/unlocked.
+ */
+#if defined(CONFIG_DEBUG_SPINLOCK) && defined(CONFIG_SMP)
+#define MUST_HOLD(lock)			BUG_ON(!spin_is_locked(lock))
+#define MUST_HOLD_RW(lock)		BUG_ON(!rwlock_is_locked(lock))
+#else
+#define MUST_HOLD(lock)			do { } while(0)
+#define MUST_HOLD_RW(lock)		do { } while(0)
+#endif /* CONFIG_DEBUG_SPINLOCK && CONFIG_SMP */
 
 #ifdef CONFIG_PREEMPT
 

  reply	other threads:[~2002-07-18 23:33 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.44L.0207061306440.8346-100000@imladris.surriel.com>
     [not found] ` <3D27390E.5060208@us.ibm.com>
2002-07-07 20:55   ` BKL removal Greg KH
2002-07-07 21:28     ` Oliver Neukum
2002-07-07 21:58       ` Dave Hansen
2002-07-07 22:38         ` Oliver Neukum
2002-07-07 21:35     ` Dave Hansen
2002-07-07 21:55       ` Thunder from the hill
2002-07-07 22:42         ` Dave Hansen
2002-07-07 23:07           ` Thunder from the hill
2002-07-07 23:23             ` Dave Hansen
2002-07-07 23:34               ` Thunder from the hill
2002-07-07 23:42                 ` Sean Neakums
2002-07-07 23:31             ` Oliver Neukum
2002-07-07 23:45               ` Dave Hansen
2002-07-08  2:34                 ` Matthew Wilcox
2002-07-08  2:52                   ` Dave Hansen
2002-07-08  3:06                     ` Alexander Viro
2002-07-08 12:33                       ` Matthew Wilcox
2002-07-08 14:53                         ` Dave Hansen
2002-07-08 12:29                     ` Matthew Wilcox
2002-07-08  2:58                   ` Alexander Viro
2002-07-08  3:06                     ` Dave Hansen
2002-07-08 12:15                     ` Matthew Wilcox
2002-07-08  6:34                 ` Oliver Neukum
2002-07-07 23:23           ` Oliver Neukum
2002-07-07 23:31             ` Dave Hansen
2002-07-07 23:51           ` Greg KH
2002-07-08  0:07             ` Dave Hansen
2002-07-08  2:12               ` Greg KH
2002-07-09  1:46                 ` Rick Lindsley
2002-07-09  4:38                   ` Greg KH
2002-07-09 19:31                     ` Rick Lindsley
2002-07-09 20:17                       ` Greg KH
2002-07-09 20:55                         ` Rick Lindsley
2002-07-09 21:00                           ` William Lee Irwin III
2002-07-09 21:12                             ` Robert Love
2002-07-09 14:19                               ` Dave Hansen
2002-07-09 21:29                                 ` Robert Love
2002-07-09 14:44                                   ` Dave Hansen
2002-07-09 21:47                                     ` Robert Love
2002-07-10  1:15                                       ` Arnaldo Carvalho de Melo
2002-07-10  3:27                                         ` Alexander Viro
2002-07-09 20:49                                           ` Dave Hansen
2002-07-10  5:30                                             ` Alexander Viro
2002-07-10 10:28                                               ` Sandy Harris
2002-07-18  0:30                                     ` David Wagner
2002-07-18  1:03                                       ` Daniel Phillips
2002-07-09 21:59                               ` William Lee Irwin III
2002-07-09 22:21                               ` Alan Cox
2002-07-10 13:31                                 ` jlnance
2002-07-10 14:17                                   ` Alan Cox
2002-07-15 20:53                                     ` Alexander Hoogerhuis
2002-07-15 22:07                                       ` Rik van Riel
2002-07-15 22:25                                         ` Thunder from the hill
2002-07-09 19:33                     ` Rick Lindsley
2002-07-09 20:12                       ` Greg KH
2002-07-09  4:49                   ` Drew P. Vogel
2002-07-09  5:25                     ` Dave Hansen
2002-07-09  5:21                   ` Larry McVoy
2002-07-09  7:59                     ` Roman Zippel
2002-07-10 10:03                     ` Marco Colombo
2002-07-10 14:40                       ` Matthew Wilcox
2002-07-10 16:46                         ` William Lee Irwin III
2002-07-11  9:57                           ` Marco Colombo
2002-07-10 21:28                     ` Rick Lindsley
2002-07-10 22:24                       ` Daniel Phillips
2002-07-10 23:36                         ` spinlock assertion macros Jesse Barnes
2002-07-11  0:54                           ` Andreas Dilger
2002-07-11  1:10                             ` Jesse Barnes
2002-07-11  5:31                           ` Daniel Phillips
2002-07-11  7:19                             ` george anzinger
2002-07-11 16:35                             ` Oliver Xymoron
2002-07-11 23:52                               ` Sandy Harris
2002-07-12  0:56                                 ` Daniel Phillips
2002-07-12  3:22                                 ` Oliver Xymoron
2002-07-11 18:03                             ` Jesse Barnes
2002-07-11 19:17                               ` Daniel Phillips
2002-07-12 12:07                                 ` Dave Jones
2002-07-12 12:55                                   ` Daniel Phillips
2002-07-12 19:24                                     ` Arnd Bergmann
2002-07-12 17:42                                       ` Daniel Phillips
2002-07-17  2:22                                         ` Jesse Barnes
2002-07-17  6:34                                           ` Daniel Phillips
2002-07-18 23:36                                             ` Jesse Barnes [this message]
2002-07-17 11:09                                           ` Arnd Bergmann
2002-07-12 20:41                                     ` Oliver Xymoron
2002-07-13  3:21                                       ` Daniel Phillips
2002-07-12 17:49                                   ` Robert Love
2002-07-12 17:58                                     ` Dave Jones
2002-07-11 10:51                           ` Arnd Bergmann
2002-07-07 22:24       ` BKL removal Greg KH
2002-07-08  0:56         ` Bernd Eckenfels
2002-07-10  0:30     ` Pavel Machek

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=20020718233613.GC763939@sgi.com \
    --to=jbarnes@sgi.com \
    --cc=arnd@bergmann-dalldorf.de \
    --cc=kernel-janitor-discuss@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillips@arcor.de \
    /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