From: Ingo Molnar <mingo@elte.hu>
To: "Barry K. Nathan" <barryn@pobox.com>
Cc: Valdis.Kletnieks@vt.edu, Andrew Morton <akpm@osdl.org>,
arjan@linux.intel.com, linux-kernel@vger.kernel.org,
reiserfs-dev@namesys.com, Hans Reiser <reiser@namesys.com>
Subject: Re: 2.6.17-rc5-mm3: bad unlock ordering (reiser4?)
Date: Mon, 5 Jun 2006 09:37:01 +0200 [thread overview]
Message-ID: <20060605073701.GA28763@elte.hu> (raw)
In-Reply-To: <20060605065444.GA27445@elte.hu>
* Ingo Molnar <mingo@elte.hu> wrote:
> +++ linux/fs/reiser4/txnmgr.h
> @@ -613,7 +613,7 @@ static inline void spin_unlock_txnmgr(tx
> LOCK_CNT_DEC(spin_locked_txnmgr);
> LOCK_CNT_DEC(spin_locked);
>
> - spin_unlock(&(mgr->tmgr_lock));
> + spin_unlock_non_nested(&(mgr->tmgr_lock));
> }
>
> typedef enum {
Btw., this particular annotation also documents a locking/scalability
inefficiency. mgr->tmgr_lock is a "global" lock (per superblock it
seems), while atom->alock is a more "finegrained" lock.
Typical usage: tmgr_lock is used a 'master lock', it's taken, then
atom->alock is taken, and then ->tmgr_lock is released. Then code runs
under atom->alock, and atom->alock is released finally.
The scalability problem with such 'master locks' is that they pretty
much control scalability, so the scalability advantage of the finer
grained lock is reduced (often eliminated). Since access to the finer
grained lock goes via the master lock, the master lock cacheline will
bounce from CPU to CPU.
A much more scalable design is to get to the finer grained lock in some
read-mostly, lockless way, and then take it. This often necessiates the
utilization of RCU, but it's well worth it.
There's other kernel code that has been annotated for similar reasons -
e.g. the netfilter code makes frequent use of master-locks.
All in one, it's a good idea to document such locking constructs via the
_non_nested() annotation. Often they can be eliminated altogether and
the code improves. It's not a maintainance problem either, because right
now there are only 42 such annotations, out of 46,000+ locking API uses
covered by the lock validator.
Ingo
next prev parent reply other threads:[~2006-06-05 7:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-04 12:04 2.6.17-rc5-mm3: bad unlock ordering (reiser4?) Barry K. Nathan
2006-06-04 14:00 ` Barry K. Nathan
2006-06-04 20:33 ` Andrew Morton
2006-06-04 20:56 ` Valdis.Kletnieks
2006-06-04 21:34 ` Ingo Molnar
2006-06-04 22:03 ` Barry K. Nathan
2006-06-05 2:46 ` Hans Reiser
2006-06-05 6:54 ` Ingo Molnar
2006-06-05 7:37 ` Ingo Molnar [this message]
2006-06-05 11:22 ` Alexander Zarochentsev
2006-06-05 12:50 ` Ingo Molnar
2006-06-05 23:56 ` Hans Reiser
2006-06-05 7:58 ` Barry K. Nathan
2006-06-05 8:12 ` Ingo Molnar
2006-06-05 9:00 ` Barry K. Nathan
2006-06-09 21:39 ` Hans Reiser
2006-06-09 21:36 ` Hans Reiser
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=20060605073701.GA28763@elte.hu \
--to=mingo@elte.hu \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@osdl.org \
--cc=arjan@linux.intel.com \
--cc=barryn@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=reiser@namesys.com \
--cc=reiserfs-dev@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