From: Peter Zijlstra <peterz@infradead.org>
To: NeilBrown <neilb@suse.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Shaohua Li <shli@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-next@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: linux-next: manual merge of the tip tree
Date: Thu, 17 Oct 2013 11:23:49 +0200 [thread overview]
Message-ID: <20131017092349.GL2675@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <20131017122859.67432627@notabene.brown>
On Thu, Oct 17, 2013 at 12:28:59PM +1100, NeilBrown wrote:
> I always run with lockdep enabled, and I have done at least basic testing
Very good!
> >
> > Stuff like:
> >
> > + for (i = 0; i < NR_STRIPE_HASH_LOCKS; i++)
> > + spin_lock_init(conf->hash_locks + i);
> >
> > And:
> >
> > +static void __lock_all_hash_locks(struct r5conf *conf)
> > +{
> > + int i;
> > + for (i = 0; i < NR_STRIPE_HASH_LOCKS; i++)
> > + spin_lock(conf->hash_locks + i);
> > +}
> >
> > Tends to complain real loud.
>
> Why is that?
> Because "conf->hash_locks + i" gets used as the "name" of the lockdep map for
> each one, and when they are all locked it looks like nested locking??
Exactly so; they all share the same class (and name) because they have
the same init site; so indeed the multiple lock will look like a nested
lock.
> Do you have a suggestion for how to make this work?
> Would
> spin_lock_nested(conf->hash_locks + i, i)
> do the trick?
spin_lock_nest_lock(conf->hash_locks + i, &conf->device_lock);
Would be the better option; your suggestion might just work because
NR_STRIP_HASH_LOCKS is 8 and we have exactly 8 subclasses available, but
any increase to NR_STRIPE_HASH_LOCKS will make things explode again.
The spin_lock_nest_lock() annotation tells that the lock order is
irrelevant because all such multiple acquisitions are serialized under
the other lock.
Also, if in future you feel the need to increase NR_STRIP_HASH_LOCKS,
please keep it <= 64 or so; if you have a need to go above that, please
yell and we'll see if we can do something smarter.
This is because of:
- each spin_lock() increases preempt_count and that's 8 bits; we
wouldn't want to overflow that
- each consecutive nested spin_lock() increases the total acquisition
wait-time for all locks. Note that the worst case acquisition time
for even a single hash lock is gated by the complete acquisition time
of all of them in this scenario.
next prev parent reply other threads:[~2013-10-17 9:23 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 18:51 linux-next: Tree for Oct 16 Thierry Reding
2013-10-16 18:51 ` linux-next: manual merge of the tip tree Thierry Reding
2013-10-16 20:06 ` Peter Zijlstra
2013-10-16 20:14 ` Peter Zijlstra
2013-10-16 20:31 ` NeilBrown
2013-10-16 20:35 ` Peter Zijlstra
2013-10-16 20:51 ` Thierry Reding
2013-10-16 21:00 ` Peter Zijlstra
2013-10-16 20:52 ` Peter Zijlstra
2013-10-17 1:28 ` NeilBrown
2013-10-17 9:23 ` Peter Zijlstra [this message]
2013-10-22 2:09 ` NeilBrown
2013-10-16 20:40 ` Thierry Reding
2013-10-16 20:44 ` Thierry Reding
2013-10-16 21:30 ` Peter Zijlstra
2013-10-17 1:29 ` NeilBrown
2013-10-16 18:51 ` linux-next: manual merge of the kvm-arm tree Thierry Reding
2013-10-16 18:58 ` Marc Zyngier
2013-10-16 19:02 ` Christoffer Dall
2013-10-16 19:04 ` Thierry Reding
2013-10-16 19:09 ` Christoffer Dall
2013-10-17 14:55 ` Gleb Natapov
2013-10-17 16:53 ` Christoffer Dall
2013-10-16 21:48 ` linux-next: Tree for Oct 16 (net/sched/em_ipset.c) Randy Dunlap
2013-10-16 22:39 ` Stephen Hemminger
2013-10-17 0:21 ` Randy Dunlap
2013-10-17 0:29 ` [PATCH net-next] em_ipset: use dev_net() accessor Stephen Hemminger
2013-10-18 20:23 ` David Miller
2013-10-17 0:58 ` linux-next: Tree for Oct 16 Randy Dunlap
2013-10-17 5:12 ` Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2013-10-24 16:31 linux-next: Tree for Oct 24 Thierry Reding
2013-10-25 13:03 ` linux-next: manual merge of the c6x tree Thierry Reding
2013-10-25 13:03 ` linux-next: manual merge of the tip tree Thierry Reding
2013-10-25 13:25 ` Will Deacon
2013-10-26 8:40 ` Ingo Molnar
2013-10-26 14:01 ` Will Deacon
2013-10-27 7:12 ` Ingo Molnar
2013-10-27 10:00 ` Russell King - ARM Linux
2013-10-28 7:47 ` Thierry Reding
2013-10-28 8:45 ` Russell King - ARM Linux
2013-10-17 21:23 Mark Brown
2013-10-17 21:50 ` Cyrill Gorcunov
2013-09-30 11:26 linux-next: manual merge of the bcon tree Thierry Reding
2013-09-30 11:26 ` linux-next: manual merge of the tip tree Thierry Reding
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=20131017092349.GL2675@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=neilb@suse.de \
--cc=shli@kernel.org \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).