From: Boqun Feng <boqun.feng@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Josh Triplett <josh@joshtriplett.org>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
sasha.levin@oracle.com, Boqun Feng <boqun.feng@gmail.com>
Subject: [RFC v2 3/6] lockdep: LOCKED_ACCESS: Maintain the keys of acqchains
Date: Tue, 16 Feb 2016 13:57:42 +0800 [thread overview]
Message-ID: <1455602265-16490-4-git-send-email-boqun.feng@gmail.com> (raw)
In-Reply-To: <1455602265-16490-1-git-send-email-boqun.feng@gmail.com>
Add held_lock::prev_acqchain_key and task_struct::curr_acqchain_key to
maintain the keys of acqchains as the same as what lockdep does for
keys of lock classes.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
include/linux/lockdep.h | 3 +++
include/linux/sched.h | 3 +++
kernel/fork.c | 3 +++
kernel/locking/lockdep.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 40 insertions(+)
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 140c1c3..2ffe6c3 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -244,6 +244,9 @@ struct held_lock {
* with zero), here we store the previous hash value:
*/
u64 prev_chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ u64 prev_acqchain_key;
+#endif
unsigned long acquire_ip;
struct lockdep_map *instance;
struct lockdep_map *nest_lock;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a10494a..c24348e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1643,6 +1643,9 @@ struct task_struct {
unsigned int lockdep_recursion;
struct held_lock held_locks[MAX_LOCK_DEPTH];
gfp_t lockdep_reclaim_gfp;
+#ifdef CONFIG_LOCKED_ACCESS
+ u64 curr_acqchain_key;
+#endif
#endif
#ifdef CONFIG_UBSAN
unsigned int in_ubsan;
diff --git a/kernel/fork.c b/kernel/fork.c
index 2e391c7..d9fc51b 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1404,6 +1404,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
p->lockdep_depth = 0; /* no locks held yet */
p->curr_chain_key = 0;
p->lockdep_recursion = 0;
+# ifdef CONFIG_LOCKED_ACCESS
+ p->curr_acqchain_key = 0;
+# endif
#endif
#ifdef CONFIG_DEBUG_MUTEXES
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index fdb1b8c..3ebd00d 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3089,6 +3089,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
int chain_head = 0;
int class_idx;
u64 chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ u64 acqchain_key;
+#endif
if (unlikely(!debug_locks))
return 0;
@@ -3196,6 +3199,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
return 0;
chain_key = curr->curr_chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ acqchain_key = curr->curr_acqchain_key;
+#endif
if (!depth) {
/*
* How can we have a chain hash when we ain't got no keys?!
@@ -3206,12 +3212,23 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
}
hlock->prev_chain_key = chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ hlock->prev_acqchain_key = acqchain_key;
+#endif
if (separate_irq_context(curr, hlock)) {
chain_key = 0;
+
+#ifdef CONFIG_LOCKED_ACCESS
+ acqchain_key = 0;
+#endif
+
chain_head = 1;
}
chain_key = iterate_chain_key(chain_key, id);
+#ifdef CONFIG_LOCKED_ACCESS
+ acqchain_key = iterate_acqchain_key(acqchain_key, ip);
+#endif
if (nest_lock && !__lock_is_held(nest_lock))
return print_lock_nested_lock_not_held(curr, hlock, ip);
@@ -3219,6 +3236,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
return 0;
curr->curr_chain_key = chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ curr->curr_acqchain_key = acqchain_key;
+#endif
curr->lockdep_depth++;
check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP
@@ -3348,6 +3368,9 @@ found_it:
curr->lockdep_depth = i;
curr->curr_chain_key = hlock->prev_chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ curr->curr_acqchain_key = hlock->prev_acqchain_key;
+#endif
for (; i < depth; i++) {
hlock = curr->held_locks + i;
@@ -3438,6 +3461,9 @@ found_it:
curr->lockdep_depth = i;
curr->curr_chain_key = hlock->prev_chain_key;
+#ifdef CONFIG_LOCKED_ACCESS
+ curr->curr_acqchain_key = hlock->prev_acqchain_key;
+#endif
for (i++; i < depth; i++) {
hlock = curr->held_locks + i;
@@ -3879,6 +3905,11 @@ void lockdep_reset(void)
raw_local_irq_save(flags);
current->curr_chain_key = 0;
+
+#ifdef CONFIG_LOCKED_ACCESS
+ current->curr_acqchain_key = 0;
+#endif
+
current->lockdep_depth = 0;
current->lockdep_recursion = 0;
memset(current->held_locks, 0, MAX_LOCK_DEPTH*sizeof(struct held_lock));
--
2.7.1
next prev parent reply other threads:[~2016-02-16 5:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 5:57 [RFC v2 0/6] Track RCU dereferences in RCU read-side critical sections Boqun Feng
2016-02-16 5:57 ` [RFC v2 1/6] lockdep: Add helper functions of irq_context Boqun Feng
2016-02-17 0:17 ` Paul E. McKenney
2016-04-23 12:53 ` [tip:locking/urgent] locking/lockdep: Fix ->irq_context calculation tip-bot for Boqun Feng
2016-02-16 5:57 ` [RFC v2 2/6] lockdep: LOCKED_ACCESS: Introduce locked access class and acqchain Boqun Feng
2016-02-16 5:57 ` Boqun Feng [this message]
2016-02-16 5:57 ` [RFC v2 4/6] lockdep: LOCKED_ACCESS: Introduce locked_access_point() Boqun Feng
2016-02-16 5:57 ` [RFC v2 5/6] lockdep: LOCKED_ACCESS: Add proc interface for locked access class Boqun Feng
2016-02-16 5:57 ` [RFC v2 6/6] RCU: Track rcu_dereference() in RCU read-side critical section Boqun Feng
2016-02-25 14:32 ` [RFC v2 0/6] Track RCU dereferences in RCU read-side critical sections Peter Zijlstra
2016-02-25 15:37 ` Paul E. McKenney
2016-02-26 3:06 ` Boqun Feng
2016-02-26 11:25 ` Peter Zijlstra
2016-02-29 1:12 ` Boqun Feng
2016-02-29 12:43 ` Peter Zijlstra
2016-03-01 9:32 ` Boqun Feng
2016-03-01 9:57 ` Peter Zijlstra
2016-03-01 10:01 ` Peter Zijlstra
2016-03-02 6:37 ` Boqun Feng
2016-03-02 10:18 ` Peter Zijlstra
2016-03-02 14:08 ` Paul E. McKenney
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=1455602265-16490-4-git-send-email-boqun.feng@gmail.com \
--to=boqun.feng@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sasha.levin@oracle.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
Powered by JetHome