mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Phillips <phillips@arcor.de>
To: Oliver Xymoron <oxymoron@waste.org>
Cc: Dave Jones <davej@suse.de>, Jesse Barnes <jbarnes@sgi.com>,
	kernel-janitor-discuss 
	<kernel-janitor-discuss@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>
Subject: Re: spinlock assertion macros
Date: Sat, 13 Jul 2002 05:21:16 +0200	[thread overview]
Message-ID: <E17TDTB-0002hg-00@starship> (raw)
In-Reply-To: <Pine.LNX.4.44.0207121533590.15441-100000@waste.org>

On Friday 12 July 2002 22:41, Oliver Xymoron wrote:
> On Fri, 12 Jul 2002, Daniel Phillips wrote:
> > On Friday 12 July 2002 14:07, Dave Jones wrote:
> > > Something I've been meaning to hack up for a while is some spinlock
> > > debugging code that adds a FUNCTION_SLEEPS() to (ta-da) functions that
> > > may sleep.
> >
> > Yesss.  May I suggest simply SLEEPS()?  (Chances are, we know it's a
> > function.)
> >
> > > This macro then checks whether we're currently holding any
> > > locks, and if so printk's the names of locks held, and where they were taken.
> >
> > And then oopes?
> >
> > > When I came up with the idea[1] I envisioned some linked-lists frobbing,
> > > but in more recent times, we can now check the preempt_count for a
> > > quick-n-dirty implementation (without the additional info of which locks
> > > we hold, lock-taker, etc).
> >
> > Spin_lock just has to store the address/location of the lock in a
> > per-cpu vector, and the assert prints that out when it oopses.  Such
> > bugs won't live too long under those conditions.
> 
> Store it in the task struct, and store a pointer to the previous (outer
> lock) in that lock, then you've got a linked list of locks per task - very
> useful.

Yes, thanks, I was in fact feeling a little guilty about proposing that
non-nested solution, even if it would in practice point you at the
correct culprit most of the time.

So in schedule() we check the task struct field and oops if it's non-null.
In other words, one instance of SLEEPS goes in shedule() and others are
sprinkled around the kernel as executable documentation.

> You'll need a helper function - current() is hard to get at from
> spinlock.h due to tangled dependencies.

What is the problem?  It looks like (struct thread_info *) can be forward
declared, and hence current_thread_info and get_current can be defined
early.  Maybe I didn't sniff at enough architectures.

Anyway, if there are nasty dependencies then they are probably similar
to the ones I unravelled with my early-page patch, which allows struct
page to be declared right at the start of mm.h instead of way later,
below a lot of things that want to reference it.

> As I mentioned before, it can also
> be very handy to stash the address of the code that took the lock in the
> lock itself.

And since the stack is chained through the locks, that just works.
 
> > Any idea how one might implement NEVER_SLEEPS()?  Maybe as:
> >
> >    NEVER_ [code goes here] _SLEEPS
> >
> > which inc/dec the preeempt count, triggering a BUG in schedule().
> 
> NEVER_SLEEPS will only trigger on the rare events that blow up anyway,
> while the MAY_SLEEP version catches _potential_ problems even when the
> fatal sleep doesn't happen.

Yes, that one's already been rejected as largely pointless.

-- 
Daniel

  reply	other threads:[~2002-07-13  3:17 UTC|newest]

Thread overview: 94+ 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                                             ` [PATCH] spinlock assertion macros for 2.5.26 Jesse Barnes
2002-07-17 11:09                                           ` spinlock assertion macros Arnd Bergmann
2002-07-12 20:41                                     ` Oliver Xymoron
2002-07-13  3:21                                       ` Daniel Phillips [this message]
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
     [not found] <0C01A29FBAE24448A792F5C68F5EA47D2B0FDD@nasdaq.ms.ensim.com>
2002-07-12  1:36 ` spinlock assertion macros pmenage
2002-07-12  4:38   ` Jesse Barnes

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=E17TDTB-0002hg-00@starship \
    --to=phillips@arcor.de \
    --cc=davej@suse.de \
    --cc=jbarnes@sgi.com \
    --cc=kernel-janitor-discuss@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oxymoron@waste.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®