[RFC/PATCH PATCH 2/6] lockdep: Remove strict read checks.

From: Gautham R Shenoy
Date: Mon May 11 2009 - 08:40:09 EST


Read locks would cause IRQ inversion problems only when they're being taken in
a IRQ context. So, except for this case, skip the strict read checks for every
other case.

Signed-off-by: Gautham R Shenoy <ego@xxxxxxxxxx>
---

kernel/lockdep.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 8d3c2b5..597479a 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1986,8 +1986,6 @@ static int RECLAIM_FS_verbose(struct lock_class *class)
return 0;
}

-#define STRICT_READ_CHECKS 1
-
static int (*state_verbose_f[])(struct lock_class *class) = {
#define LOCKDEP_STATE(__STATE) \
__STATE##_verbose,
@@ -2032,9 +2030,13 @@ mark_lock_irq(struct task_struct *curr, struct held_lock *this,
/*
* Validate that the lock dependencies don't have conflicting usage
* states.
+ *
+ * Skip the part if it's a read_lock with LOCK_ENABLED_XXX.
+ * We'll do that check when a write variant of the same lock is taken,
+ * or we take the read variant of lock in the LOCK_USED_IN_XXX state.
*/
- if ((!read || !dir || STRICT_READ_CHECKS) &&
- !usage(curr, this, excl_bit, state_name(new_bit & ~1)))
+ if (!(read && dir) && !usage(curr, this, excl_bit,
+ state_name(new_bit & ~1)))
return 0;

/*
@@ -2044,8 +2046,7 @@ mark_lock_irq(struct task_struct *curr, struct held_lock *this,
if (!valid_state(curr, this, new_bit, excl_bit + 1))
return 0;

- if (STRICT_READ_CHECKS &&
- !usage(curr, this, excl_bit + 1,
+ if (!usage(curr, this, excl_bit + 1,
state_name(new_bit + 1)))
return 0;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/