From: Steven Rostedt <[email protected]>
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.
Acked-by: Peter Zijlstra <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
kernel/lockdep.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 3b1ac92..60bce52 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1973,7 +1973,7 @@ static inline int lookup_chain_cache(struct task_struct *curr,
struct list_head *hash_head = chainhashentry(chain_key);
struct lock_chain *chain;
struct held_lock *hlock_curr, *hlock_next;
- int i, j, n, cn;
+ int i, j;
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
return 0;
@@ -2033,15 +2033,9 @@ cache_hit:
}
i++;
chain->depth = curr->lockdep_depth + 1 - i;
- cn = nr_chain_hlocks;
- while (cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS) {
- n = cmpxchg(&nr_chain_hlocks, cn, cn + chain->depth);
- if (n == cn)
- break;
- cn = n;
- }
- if (likely(cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
- chain->base = cn;
+ if (likely(nr_chain_hlocks + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
+ chain->base = nr_chain_hlocks;
+ nr_chain_hlocks += chain->depth;
for (j = 0; j < chain->depth - 1; j++, i++) {
int lock_id = curr->held_locks[i].class_idx - 1;
chain_hlocks[chain->base + j] = lock_id;
--
1.7.2.3
On Thu, Apr 21, 2011 at 9:42 AM, Steven Rostedt <[email protected]> wrote:
> From: Steven Rostedt <[email protected]>
>
> 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.
>
> Acked-by: Peter Zijlstra <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> kernel/lockdep.c | 14 ++++----------
> 1 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/lockdep.c b/kernel/lockdep.c
> index 3b1ac92..60bce52 100644
> --- a/kernel/lockdep.c
> +++ b/kernel/lockdep.c
> @@ -1973,7 +1973,7 @@ static inline int lookup_chain_cache(struct task_struct *curr,
> struct list_head *hash_head = chainhashentry(chain_key);
> struct lock_chain *chain;
> struct held_lock *hlock_curr, *hlock_next;
Maybe we can also remove hlock_next in this function for some cleanup, because
it's just an alias of hlock.
Thanks,
Yong
> - int i, j, n, cn;
> + int i, j;
>
> if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
> return 0;
> @@ -2033,15 +2033,9 @@ cache_hit:
> }
> i++;
> chain->depth = curr->lockdep_depth + 1 - i;
> - cn = nr_chain_hlocks;
> - while (cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS) {
> - n = cmpxchg(&nr_chain_hlocks, cn, cn + chain->depth);
> - if (n == cn)
> - break;
> - cn = n;
> - }
> - if (likely(cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
> - chain->base = cn;
> + if (likely(nr_chain_hlocks + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
> + chain->base = nr_chain_hlocks;
> + nr_chain_hlocks += chain->depth;
> for (j = 0; j < chain->depth - 1; j++, i++) {
> int lock_id = curr->held_locks[i].class_idx - 1;
> chain_hlocks[chain->base + j] = lock_id;
> --
> 1.7.2.3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Only stand for myself
Commit-ID: e0944ee63f7249802be74454cef81c97630ae1cd
Gitweb: http://git.kernel.org/tip/e0944ee63f7249802be74454cef81c97630ae1cd
Author: Steven Rostedt <[email protected]>
AuthorDate: Wed, 20 Apr 2011 21:42:00 -0400
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 22 Apr 2011 11:06:59 +0200
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: Steven Rostedt <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Andrew Morton <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/lockdep.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 27c609f..63437d0 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1973,7 +1973,7 @@ static inline int lookup_chain_cache(struct task_struct *curr,
struct list_head *hash_head = chainhashentry(chain_key);
struct lock_chain *chain;
struct held_lock *hlock_curr, *hlock_next;
- int i, j, n, cn;
+ int i, j;
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
return 0;
@@ -2033,15 +2033,9 @@ cache_hit:
}
i++;
chain->depth = curr->lockdep_depth + 1 - i;
- cn = nr_chain_hlocks;
- while (cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS) {
- n = cmpxchg(&nr_chain_hlocks, cn, cn + chain->depth);
- if (n == cn)
- break;
- cn = n;
- }
- if (likely(cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
- chain->base = cn;
+ if (likely(nr_chain_hlocks + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) {
+ chain->base = nr_chain_hlocks;
+ nr_chain_hlocks += chain->depth;
for (j = 0; j < chain->depth - 1; j++, i++) {
int lock_id = curr->held_locks[i].class_idx - 1;
chain_hlocks[chain->base + j] = lock_id;