提交 e0944ee6 编写于 作者: S Steven Rostedt 提交者: Ingo Molnar

lockdep: Remove cmpxchg to update nr_chain_hlocks

For some reason nr_chain_hlocks is updated with cmpxchg, but
this is performed inside of the lockdep global "grab_lock()",
which also makes simple modification of this variable atomic.

Remove the cmpxchg logic for updating nr_chain_hlocks and
simplify the code.
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20110421014300.727863282@goodmis.orgSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 282b5c2f
...@@ -1973,7 +1973,7 @@ static inline int lookup_chain_cache(struct task_struct *curr, ...@@ -1973,7 +1973,7 @@ static inline int lookup_chain_cache(struct task_struct *curr,
struct list_head *hash_head = chainhashentry(chain_key); struct list_head *hash_head = chainhashentry(chain_key);
struct lock_chain *chain; struct lock_chain *chain;
struct held_lock *hlock_curr, *hlock_next; struct held_lock *hlock_curr, *hlock_next;
int i, j, n, cn; int i, j;
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
return 0; return 0;
...@@ -2033,15 +2033,9 @@ static inline int lookup_chain_cache(struct task_struct *curr, ...@@ -2033,15 +2033,9 @@ static inline int lookup_chain_cache(struct task_struct *curr,
} }
i++; i++;
chain->depth = curr->lockdep_depth + 1 - i; chain->depth = curr->lockdep_depth + 1 - i;
cn = nr_chain_hlocks; if (likely(nr_chain_hlocks + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
while (cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS) { chain->base = nr_chain_hlocks;
n = cmpxchg(&nr_chain_hlocks, cn, cn + chain->depth); nr_chain_hlocks += chain->depth;
if (n == cn)
break;
cn = n;
}
if (likely(cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
chain->base = cn;
for (j = 0; j < chain->depth - 1; j++, i++) { for (j = 0; j < chain->depth - 1; j++, i++) {
int lock_id = curr->held_locks[i].class_idx - 1; int lock_id = curr->held_locks[i].class_idx - 1;
chain_hlocks[chain->base + j] = lock_id; chain_hlocks[chain->base + j] = lock_id;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册