summaryrefslogtreecommitdiff
path: root/kernel/lockdep.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-01-27 14:53:50 +0100
committerIngo Molnar <mingo@elte.hu>2009-02-14 23:28:19 +0100
commit38aa2714382d886f77f2565277fce293122808b0 (patch)
tree3a6511ff0629b785f5685de987a319047c780781 /kernel/lockdep.c
parentcf2ad4d13c4ac6366c730fcf6c6be00db12fb75f (diff)
downloadkernel-common-38aa2714382d886f77f2565277fce293122808b0.tar.gz
kernel-common-38aa2714382d886f77f2565277fce293122808b0.tar.bz2
kernel-common-38aa2714382d886f77f2565277fce293122808b0.zip
lockdep: add comments to mark_lock_irq()
re-add some of the comments that got lost in the refactoring. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r--kernel/lockdep.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index f40d916c191c..02e6e066d563 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2054,6 +2054,9 @@ static int exclusive_bit(int new_bit)
int state = new_bit & ~3;
int dir = new_bit & 2;
+ /*
+ * keep state, bit flip the direction and strip read.
+ */
return state | (dir ^ 2);
}
@@ -2070,22 +2073,42 @@ mark_lock_irq(struct task_struct *curr, struct held_lock *this, int new_bit)
int read = new_bit & 1;
int dir = new_bit & 2;
+ /*
+ * mark USED_IN has to look forwards -- to ensure no dependency
+ * has ENABLED state, which would allow recursion deadlocks.
+ *
+ * mark ENABLED has to look backwards -- to ensure no dependee
+ * has USED_IN state, which, again, would allow recursion deadlocks.
+ */
check_usage_f usage = dir ?
check_usage_backwards : check_usage_forwards;
+ /*
+ * Validate that this particular lock does not have conflicting
+ * usage states.
+ */
if (!valid_state(curr, this, new_bit, excl_bit))
return 0;
- if (!read && !valid_state(curr, this, new_bit, excl_bit + 1))
- return 0;
-
- if ((!read || (!dir || STRICT_READ_CHECKS)) &&
+ /*
+ * Validate that the lock dependencies don't have conflicting usage
+ * states.
+ */
+ if ((!read || !dir || STRICT_READ_CHECKS) &&
!usage(curr, this, excl_bit, name))
return 0;
- if ((!read && STRICT_READ_CHECKS) &&
- !usage(curr, this, excl_bit + 1, rname))
- return 0;
+ /*
+ * Check for read in write conflicts
+ */
+ if (!read) {
+ if (!valid_state(curr, this, new_bit, excl_bit + 1))
+ return 0;
+
+ if (STRICT_READ_CHECKS &&
+ !usage(curr, this, excl_bit + 1, rname))
+ return 0;
+ }
if (state_verbose(new_bit, hlock_class(this)))
return 2;