* [PATCH] LOCKDEP: fix mismatched lockdep_depth/curr_chain_hash
@ 2007-10-05 4:03 Gregory Haskins
2007-10-05 9:31 ` [PATCH] lockdep: " Peter Zijlstra
0 siblings, 1 reply; 7+ messages in thread
From: Gregory Haskins @ 2007-10-05 4:03 UTC (permalink / raw)
To: mingo; +Cc: linux-kernel, linux-rt-users, ghaskins
Hi Ingo,
I am seeing a problem on the latest -rt where lockdep completely overwhelms
the system to the point that it grinds to a halt on large (8-way+) systems.
The problem seems to be that the class->locks_before and locks_after grow
unbounded (I have observed over 1M+ entries in them) so a lock_acquire call
can take over 10 seconds to finish resolving. Related to this seems to be
that lockdep appears to see a chain-hash miss over and over for what I would
assume should be an established graph (for instance, in
double_lock_balance() in an rt_overload condition). Turning off
PROVE_LOCKING (statically, or by setting debug_locks=0 dynamically restores
the system to normal behavior.
I took some time tonight to study lockdep (it is quite an impressive body of
code!), and came up with the following "fix". It does improve things
significantly by addressing what I believe is the issue with the
cache-misses (though it would appear there are still a few more issues
there that need addressing as some boots are still very lethargic). I use
the term "fix" loosely since I am not confident that I fully understand the
intention of your logic here so I can't say for sure if it was really
broken, or if I have made it worse ;)
Could you comment on what I have done here, or offer any advice on what to
look for elsewhere? I based the patch on pure linux-2.6.git since I see the
same issue (by visual inspection, that is) there as well.
Thanks in advance!
-Greg
------
LOCKDEP: fix mismatched lockdep_depth/curr_chain_hash
It is possible for the current->curr_chain_key to become inconsistent with the
current index if the chain fails to validate. The end result is that future
lock_acquire() operations may inadvertently fail to find a hit in the cache
resulting in a new node being added to the graph for every acquire.
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
---
kernel/lockdep.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 734da57..efb0d7e 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2450,11 +2450,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
chain_head = 1;
}
chain_key = iterate_chain_key(chain_key, id);
- curr->curr_chain_key = chain_key;
if (!validate_chain(curr, lock, hlock, chain_head))
return 0;
+ curr->curr_chain_key = chain_key;
curr->lockdep_depth++;
check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] LOCKDEP: fix mismatched lockdep_depth/curr_chain_hash
@ 2007-10-05 4:22 Gregory Haskins
2007-10-05 9:31 ` [PATCH] lockdep: " Peter Zijlstra
0 siblings, 1 reply; 7+ messages in thread
From: Gregory Haskins @ 2007-10-05 4:22 UTC (permalink / raw)
To: mingo; +Cc: linux-kernel, linux-rt-users, ghaskins
Doh! I guess there should be a rule about sending patches out after midnight
;)
The original patch I worked on was written before the code was moved to
validate_chain(), so my previous posting didnt quite translate when I merged
with git HEAD. Here is an updated patch. Sorry for the confusion.
Regards,
-Greg
---
kernel/lockdep.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 734da57..42ae4a5 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1521,7 +1521,7 @@ cache_hit:
}
static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
- struct held_lock *hlock, int chain_head)
+ struct held_lock *hlock, int chain_head, u64 chain_key)
{
/*
* Trylock needs to maintain the stack of held locks, but it
@@ -1534,7 +1534,7 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
* graph_lock for us)
*/
if (!hlock->trylock && (hlock->check == 2) &&
- lookup_chain_cache(curr->curr_chain_key, hlock->class)) {
+ lookup_chain_cache(chain_key, hlock->class)) {
/*
* Check whether last held lock:
*
@@ -1576,7 +1576,7 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
#else
static inline int validate_chain(struct task_struct *curr,
struct lockdep_map *lock, struct held_lock *hlock,
- int chain_head)
+ int chain_head, u64 chain_key)
{
return 1;
}
@@ -2450,11 +2450,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
chain_head = 1;
}
chain_key = iterate_chain_key(chain_key, id);
- curr->curr_chain_key = chain_key;
- if (!validate_chain(curr, lock, hlock, chain_head))
+ if (!validate_chain(curr, lock, hlock, chain_head, chain_key))
return 0;
+ curr->curr_chain_key = chain_key;
curr->lockdep_depth++;
check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash
2007-10-05 4:22 [PATCH] LOCKDEP: " Gregory Haskins
@ 2007-10-05 9:31 ` Peter Zijlstra
0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-10-05 9:31 UTC (permalink / raw)
To: Gregory Haskins, Andrew Morton, Linus Torvalds; +Cc: mingo, linux-kernel
Ouch!
Thanks Gregory for finding this!
I'll send your initial patch to the stable team for .22.
---
Subject: lockdep: fix mismatched lockdep_depth/curr_chain_hash
From: Gregory Haskins <ghaskins@novell.com>
It is possible for the current->curr_chain_key to become inconsistent with the
current index if the chain fails to validate. The end result is that future
lock_acquire() operations may inadvertently fail to find a hit in the cache
resulting in a new node being added to the graph for every acquire.
[ peterz: this might explain some of the lockdep is so _slow_ complaints. ]
[ mingo: this does not impact the correctness of validation, but may slow
down future operations significantly, if the chain gets very long. ]
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/lockdep.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Index: linux-2.6/kernel/lockdep.c
===================================================================
--- linux-2.6.orig/kernel/lockdep.c
+++ linux-2.6/kernel/lockdep.c
@@ -1521,7 +1521,7 @@ cache_hit:
}
static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
- struct held_lock *hlock, int chain_head)
+ struct held_lock *hlock, int chain_head, u64 chain_key)
{
/*
* Trylock needs to maintain the stack of held locks, but it
@@ -1534,7 +1534,7 @@ static int validate_chain(struct task_st
* graph_lock for us)
*/
if (!hlock->trylock && (hlock->check == 2) &&
- lookup_chain_cache(curr->curr_chain_key, hlock->class)) {
+ lookup_chain_cache(chain_key, hlock->class)) {
/*
* Check whether last held lock:
*
@@ -1576,7 +1576,7 @@ static int validate_chain(struct task_st
#else
static inline int validate_chain(struct task_struct *curr,
struct lockdep_map *lock, struct held_lock *hlock,
- int chain_head)
+ int chain_head, u64 chain_key)
{
return 1;
}
@@ -2450,11 +2450,11 @@ static int __lock_acquire(struct lockdep
chain_head = 1;
}
chain_key = iterate_chain_key(chain_key, id);
- curr->curr_chain_key = chain_key;
- if (!validate_chain(curr, lock, hlock, chain_head))
+ if (!validate_chain(curr, lock, hlock, chain_head, chain_key))
return 0;
+ curr->curr_chain_key = chain_key;
curr->lockdep_depth++;
check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash
2007-10-05 4:03 [PATCH] LOCKDEP: " Gregory Haskins
@ 2007-10-05 9:31 ` Peter Zijlstra
0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-10-05 9:31 UTC (permalink / raw)
To: Gregory Haskins, stable; +Cc: mingo, linux-kernel
Stable team,
please consider this patch for the next 22-stable.
---
Subject: lockdep: fix mismatched lockdep_depth/curr_chain_hash
From: Gregory Haskins <ghaskins@novell.com>
It is possible for the current->curr_chain_key to become inconsistent with the
current index if the chain fails to validate. The end result is that future
lock_acquire() operations may inadvertently fail to find a hit in the cache
resulting in a new node being added to the graph for every acquire.
[ peterz: this might explain some of the lockdep is so _slow_ complaints. ]
[ mingo: this does not impact the correctness of validation, but may slow
down future operations significantly, if the chain gets very long. ]
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/lockdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6/kernel/lockdep.c
===================================================================
--- linux-2.6.orig/kernel/lockdep.c
+++ linux-2.6/kernel/lockdep.c
@@ -2166,7 +2166,6 @@ out_calc_hash:
}
#endif
chain_key = iterate_chain_key(chain_key, id);
- curr->curr_chain_key = chain_key;
/*
* Trylock needs to maintain the stack of held locks, but it
@@ -2215,6 +2214,7 @@ out_calc_hash:
if (unlikely(!debug_locks))
return 0;
+ curr->curr_chain_key = chain_key;
curr->lockdep_depth++;
check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash
@ 2007-10-31 15:44 Gregory Haskins
2007-10-31 16:19 ` Peter Zijlstra
2007-10-31 16:24 ` [stable] " Greg KH
0 siblings, 2 replies; 7+ messages in thread
From: Gregory Haskins @ 2007-10-31 15:44 UTC (permalink / raw)
To: Greg KH
Cc: Chuck Ebbert, Gregory Haskins, Peter Zijlstra, stable, mingo,
linux-kernel
Hi Greg,
Here is the backported version of the patch. I applied it on top of
2.6.22.10. Let me know if you have any issues.
-Greg
------------------------------
lockdep: fix mismatched lockdep_depth/curr_chain_hash
It is possible for the current->curr_chain_key to become inconsistent with the
current index if the chain fails to validate. The end result is that future
lock_acquire() operations may inadvertently fail to find a hit in the cache
resulting in a new node being added to the graph for every acquire.
[ peterz: this might explain some of the lockdep is so _slow_ complaints. ]
[ mingo: this does not impact the correctness of validation, but may slow
down future operations significantly, if the chain gets very long. ]
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/lockdep.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 1a5ff22..072cf25 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2166,7 +2166,6 @@ out_calc_hash:
}
#endif
chain_key = iterate_chain_key(chain_key, id);
- curr->curr_chain_key = chain_key;
/*
* Trylock needs to maintain the stack of held locks, but it
@@ -2215,6 +2214,7 @@ out_calc_hash:
if (unlikely(!debug_locks))
return 0;
+ curr->curr_chain_key = chain_key;
curr->lockdep_depth++;
check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash
2007-10-31 15:44 [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash Gregory Haskins
@ 2007-10-31 16:19 ` Peter Zijlstra
2007-10-31 16:24 ` [stable] " Greg KH
1 sibling, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-10-31 16:19 UTC (permalink / raw)
To: Gregory Haskins; +Cc: Greg KH, Chuck Ebbert, stable, mingo, linux-kernel
On Wed, 2007-10-31 at 11:44 -0400, Gregory Haskins wrote:
> Hi Greg,
> Here is the backported version of the patch. I applied it on top of
> 2.6.22.10. Let me know if you have any issues.
>
> -Greg
Thanks Gregory!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [stable] [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash
2007-10-31 15:44 [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash Gregory Haskins
2007-10-31 16:19 ` Peter Zijlstra
@ 2007-10-31 16:24 ` Greg KH
1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2007-10-31 16:24 UTC (permalink / raw)
To: Gregory Haskins; +Cc: Peter Zijlstra, linux-kernel, Chuck Ebbert, mingo, stable
On Wed, Oct 31, 2007 at 11:44:05AM -0400, Gregory Haskins wrote:
> Hi Greg,
> Here is the backported version of the patch. I applied it on top of
> 2.6.22.10. Let me know if you have any issues.
Looks good, thanks. I've added it to the -stable queue and will add it
to the current 2.6.22-stable release.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-10-31 16:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-31 15:44 [PATCH] lockdep: fix mismatched lockdep_depth/curr_chain_hash Gregory Haskins
2007-10-31 16:19 ` Peter Zijlstra
2007-10-31 16:24 ` [stable] " Greg KH
-- strict thread matches above, loose matches on Subject: below --
2007-10-05 4:22 [PATCH] LOCKDEP: " Gregory Haskins
2007-10-05 9:31 ` [PATCH] lockdep: " Peter Zijlstra
2007-10-05 4:03 [PATCH] LOCKDEP: " Gregory Haskins
2007-10-05 9:31 ` [PATCH] lockdep: " Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox