public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Andrew Morton <akpm@osdl.org>,
	sekharan@us.ibm.com, torvalds@osdl.org,
	linux-kernel@vger.kernel.org, nagar@watson.ibm.com,
	balbir@in.ibm.com, arjan@infradead.org
Subject: Re: [patch] lockdep: annotate mm/slab.c
Date: Thu, 13 Jul 2006 21:32:28 +0200	[thread overview]
Message-ID: <20060713193228.GA27360@elte.hu> (raw)
In-Reply-To: <84144f020607130858l60792ac0t5f9cdabf1902339c@mail.gmail.com>


* Pekka Enberg <penberg@cs.helsinki.fi> wrote:

> On 7/13/06, Ingo Molnar <mingo@elte.hu> wrote:
> >mm/slab.c uses nested locking when dealing with 'off-slab'
> >caches, in that case it allocates the slab header from the
> >(on-slab) kmalloc caches. Teach the lock validator about
> >this by putting all on-slab caches into a separate class.
> 
> What's "nested lock" btw? If I understood from the other patch, you're 
> talking about ac->lock. Surely you can't take the same lock twice but 
> it's perfectly legal to take lock as long as the ac instance is 
> different...

yeah - there's some ambiguity of the term "nested lock". For the lock 
validator it means "holding two instances of the same lock class". A 
"lock class" is something like inode->i_mutex. (standalone static locks 
like cache_chain_mutex form their own singleton lock class. See 
Documentation/lockdep-design.txt for more details.)

"trying to lock the same lock instance twice" we call "recursive 
locking", and that's a bug for everything except read_lock() on rwlocks. 
There is no "recursive locking" in slab.c, but there is "nested 
locking". For the case of "nested locking" the lock validator needs to 
be taught of the relation between instances. Most of the cases the 
relation is "static" and can thus be assigned build-time via the use of 
separate lock-keys that "split up" a class into subclasses. In rare 
cases the relation is dynamic (for example the VFS has such nesting 
rules).

initially i annotated slab.c via dynamic nesting - but as Arjan has 
correctly observed, most of the nested locking in slab.c is of static 
type: we first take the off-slab lock, then the on-slab lock. [or we 
only take an on-slab lock, if the cache is on-slab]

Note: nested locking annotations arent just done to "shut up" lockdep, 
but rather to enable lockdep from now on to enforce this dependency 
rule: if anywhere we take an off-slab lock after an on-slab lock it will 
print a warning. That's why we go the trouble of identifying all the 
nested locking cases instead of going the easy path of "shutting lockdep 
off" (we could trivially ignore nesting within lockdep.c) - there were a 
couple of locking bugs found already that were related to nested 
locking.

btw., there's still one nested locking construct in slab.c that could 
cause problems:

 Call Trace:
  [<ffffffff8020b0b9>] show_trace+0xaa/0x23d
  [<ffffffff8020b261>] dump_stack+0x15/0x17
  [<ffffffff802456c4>] __lock_acquire+0x127/0x9c4
  [<ffffffff8024648b>] lock_acquire+0x4b/0x6a
  [<ffffffff804aead3>] _spin_lock+0x25/0x31
  [<ffffffff8027301a>] __drain_alien_cache+0x34/0x78
  [<ffffffff80272b1f>] __cache_free+0xe8/0x215
  [<ffffffff80272dc4>] slab_destroy+0x9e/0xc2
  [<ffffffff80272ed3>] free_block+0xeb/0x135
  [<ffffffff80273043>] __drain_alien_cache+0x5d/0x78
  [<ffffffff80272b1f>] __cache_free+0xe8/0x215
  [<ffffffff80273203>] kfree+0x8c/0xb0

what guarantees that while we are 'draining' another node's cache, that 
other node does not drain our cache (and thus we'd deadlock)?

	Ingo

  parent reply	other threads:[~2006-07-13 19:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-13  3:59 Random panics seen in 2.6.18-rc1 Chandra Seetharaman
2006-07-13  7:12 ` Ingo Molnar
2006-07-13  7:28   ` Andrew Morton
2006-07-13  7:26     ` Ingo Molnar
2006-07-13  7:44       ` Andrew Morton
2006-07-13  7:46         ` Ingo Molnar
2006-07-13  8:49           ` Ingo Molnar
2006-07-13  8:42         ` Ingo Molnar
2006-07-13  8:46           ` [patch] lockdep: more annotations for mm/slab.c Ingo Molnar
2006-07-13  9:08             ` Andrew Morton
2006-07-13  9:18               ` Ingo Molnar
2006-07-13 10:44                 ` Arjan van de Ven
2006-07-13 10:58                   ` Arjan van de Ven
2006-07-13 12:44         ` [patch] lockdep: undo mm/slab.c annotation Ingo Molnar
2006-07-13 12:46         ` [patch] lockdep: annotate mm/slab.c Ingo Molnar
2006-07-13 15:45           ` Pekka Enberg
2006-07-13 19:55             ` Ingo Molnar
2006-07-13 15:58           ` Pekka Enberg
2006-07-13 18:56             ` Linus Torvalds
2006-07-13 19:21               ` Arjan van de Ven
2006-07-13 22:27                 ` Christoph Lameter
2006-07-13 23:08                   ` Alok kataria
2006-07-13 22:51                 ` Christoph Lameter
2006-07-13 23:16                   ` Andrew Morton
2006-07-14  2:29                     ` Christoph Lameter
2006-07-14  2:46                       ` Christoph Lameter
2006-07-14  3:02                         ` Andrew Morton
2006-07-14  3:35                           ` Christoph Lameter
2006-07-14  3:45                             ` Christoph Lameter
2006-07-14 16:48                               ` Alok kataria
2006-07-14  2:54                       ` Andrew Morton
2006-07-14  2:59                         ` Christoph Lameter
2006-07-13 19:32             ` Ingo Molnar [this message]
2006-07-13 18:50           ` Linus Torvalds
2006-07-13 19:06             ` Arjan van de Ven
2006-07-13 19:21               ` Linus Torvalds
2006-07-13 19:26                 ` Arjan van de Ven
2006-07-13 19:17             ` Ingo Molnar
2006-07-13 19:19               ` Ingo Molnar
2006-07-13 21:30             ` Andrew Morton
2006-07-13 13:51   ` Random panics seen in 2.6.18-rc1 Chandra Seetharaman
2006-07-13 16:05     ` Chandra Seetharaman

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=20060713193228.GA27360@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=balbir@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nagar@watson.ibm.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=sekharan@us.ibm.com \
    --cc=torvalds@osdl.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