From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [RFC][PATCH 4/7] lockdep: Seperate lock ids for read/write acquires
Date: Mon, 18 Apr 2011 18:49:38 +0200 [thread overview]
Message-ID: <1303145378.32491.889.camel@twins> (raw)
In-Reply-To: <1303145177.7181.46.camel@gandalf.stny.rr.com>
On Mon, 2011-04-18 at 12:46 -0400, Steven Rostedt wrote:
> > +/*
> > + * A lock's class id is used to calculate the chain-key. Since we need to
> > + * differentiate between the chains which contain the read acquire of
> > + * a lock from the chains having write acquire of the same lock,
> > + * we offset the class_idx by MAX_LOCKDEP_KEYS if it is a read acquire.
>
> Don't we only care to do this if we have a recursive read? I thought
> simple reads still work fine with the current algorithm?
>
> > + *
> > + * Thus the the lock's key during a chain-key calculation can be in the range
> > + * 1 to 2 * MAX_LOCKDEP_KEYS - 1.
> > + *
> > + * LOCKDEP_CHAIN_KEY_BITS holds the number of bits required to
> > + * represent this range.
> > + */
> > +#define LOCKDEP_CHAIN_KEY_BITS (MAX_LOCKDEP_KEYS_BITS + 1)
> > struct held_lock {
> > /*
> > * One-way hash of the dependency chain up to this point. We
> > Index: linux-2.6/kernel/lockdep.c
> > ===================================================================
> > --- linux-2.6.orig/kernel/lockdep.c
> > +++ linux-2.6/kernel/lockdep.c
> > @@ -303,8 +303,8 @@ static struct list_head chainhash_table[
> > * unique.
> > */
> > #define iterate_chain_key(key1, key2) \
> > - (((key1) << MAX_LOCKDEP_KEYS_BITS) ^ \
> > - ((key1) >> (64-MAX_LOCKDEP_KEYS_BITS)) ^ \
> > + (((key1) << LOCKDEP_CHAIN_KEY_BITS) ^ \
> > + ((key1) >> (64 - LOCKDEP_CHAIN_KEY_BITS)) ^ \
> > (key2))
> >
> > void lockdep_off(void)
> > @@ -1988,6 +1988,9 @@ static void check_chain_key(struct task_
> > if (DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS))
> > return;
> >
> > + if (is_read(hlock->rw_state))
> > + id += MAX_LOCKDEP_KEYS;
>
> Again, isn't this about recursive reads? Or am I just confused ;)
So what we do here is split off the write chain, the above could have
been writeen if (!is_write()) to clarify that.
Everything except recursive read validation will traverse both chains,
the recursive read validation will only traverse the write chains and
ignore the combined read/recursive-read chain.
next prev parent reply other threads:[~2011-04-18 16:50 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-17 9:45 [RFC][PATCH 0/7] lockdep: Support recurise-read locks Peter Zijlstra
2011-04-17 9:45 ` [RFC][PATCH 1/7] lockdep: Implement extra recursive-read lock tests Peter Zijlstra
2011-04-17 9:45 ` [RFC][PATCH 2/7] lockdep: Remove redundant read checks Peter Zijlstra
2011-04-18 14:28 ` Steven Rostedt
2011-04-17 9:45 ` [RFC][PATCH 3/7] lockdep: Annotate read/write states Peter Zijlstra
2011-04-18 13:34 ` Yong Zhang
2011-04-18 16:34 ` Steven Rostedt
2011-04-18 16:36 ` Peter Zijlstra
2011-04-18 16:26 ` Steven Rostedt
2011-04-18 16:27 ` Steven Rostedt
2011-04-18 16:31 ` Steven Rostedt
2011-04-17 9:45 ` [RFC][PATCH 4/7] lockdep: Seperate lock ids for read/write acquires Peter Zijlstra
2011-04-18 16:46 ` Steven Rostedt
2011-04-18 16:49 ` Peter Zijlstra [this message]
2011-04-18 17:33 ` Steven Rostedt
2011-04-18 22:07 ` Peter Zijlstra
2011-04-17 9:45 ` [RFC][PATCH 5/7] lockdep: Rename lock_list::class Peter Zijlstra
2011-04-17 9:45 ` [RFC][PATCH 6/7] lockdep: Maintain rw_state entries in locklist Peter Zijlstra
2011-04-18 13:37 ` Yong Zhang
2011-04-17 9:45 ` [RFC][PATCH 7/7] lockdep: Consider the rw_state of lock while validating the chain Peter Zijlstra
2011-04-18 3:41 ` [RFC][PATCH 0/7] lockdep: Support recurise-read locks Tetsuo Handa
2011-04-22 7:19 ` Yong Zhang
2011-04-22 7:27 ` Yong Zhang
2011-04-22 7:44 ` Tetsuo Handa
2011-04-22 8:01 ` Yong Zhang
2011-04-22 8:31 ` Tetsuo Handa
2011-04-22 8:59 ` Yong Zhang
2011-04-22 9:19 ` Tetsuo Handa
2011-04-23 12:33 ` [PATCH] lockdep: ignore cached chain key for recursive read Yong Zhang
2011-04-23 13:04 ` Tetsuo Handa
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=1303145378.32491.889.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.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