aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/lockdep.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-01-22 10:51:29 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-14 17:28:12 -0500
commit780e820b2dfefdfead9243724c2d2b73f379fda6 (patch)
tree7eb55c3e4535d8404ddaf28a279637c922382952 /kernel/lockdep.c
parentcd95302d255264c5e6ebe1063320d80517bf2f83 (diff)
lockdep: merge the _READ mark_lock_irq() helpers
The _READ helpers show remarkable similarity, merge them. 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.c61
1 files changed, 23 insertions, 38 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index e0a027d58da..2d95f9db259 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2091,22 +2091,34 @@ mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this,
2091} 2091}
2092 2092
2093static int 2093static int
2094mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, 2094mark_lock_irq_read(struct task_struct *curr, struct held_lock *this,
2095 int new_bit) 2095 int new_bit)
2096{ 2096{
2097 const char *name = state_name(new_bit); 2097 const char *name = state_name(new_bit);
2098 const char *rname = state_rname(new_bit); 2098 const char *rname = state_rname(new_bit);
2099 2099
2100 int excl_bit = exclusive_bit(new_bit); 2100 int excl_bit = exclusive_bit(new_bit);
2101 int dir = new_bit & 2;
2101 2102
2102 if (!valid_state(curr, this, new_bit, excl_bit)) 2103 if (!valid_state(curr, this, new_bit, excl_bit))
2103 return 0; 2104 return 0;
2104 /* 2105
2105 * just marked it hardirq-read-safe, check that this lock 2106 if (!dir) {
2106 * took no hardirq-unsafe lock in the past: 2107 /*
2107 */ 2108 * just marked it hardirq-read-safe, check that this lock
2108 if (!check_usage_forwards(curr, this, excl_bit, name)) 2109 * took no hardirq-unsafe lock in the past:
2109 return 0; 2110 */
2111 if (!check_usage_forwards(curr, this, excl_bit, name))
2112 return 0;
2113 } else if (STRICT_READ_CHECKS) {
2114 /*
2115 * just marked it hardirq-read-unsafe, check that no
2116 * hardirq-safe lock in the system ever took it in the past:
2117 */
2118 if (!check_usage_backwards(curr, this, excl_bit, name))
2119 return 0;
2120 }
2121
2110 if (state_verbose(new_bit, hlock_class(this))) 2122 if (state_verbose(new_bit, hlock_class(this)))
2111 return 2; 2123 return 2;
2112 2124
@@ -2147,31 +2159,6 @@ mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this,
2147 return 1; 2159 return 1;
2148} 2160}
2149 2161
2150static int
2151mark_lock_irq_enabled_read(struct task_struct *curr, struct held_lock *this,
2152 int new_bit)
2153{
2154 const char *name = state_name(new_bit);
2155 const char *rname = state_rname(new_bit);
2156
2157 int excl_bit = exclusive_bit(new_bit);
2158
2159 if (!valid_state(curr, this, new_bit, excl_bit))
2160 return 0;
2161#if STRICT_READ_CHECKS
2162 /*
2163 * just marked it hardirq-read-unsafe, check that no
2164 * hardirq-safe lock in the system ever took it in the past:
2165 */
2166 if (!check_usage_backwards(curr, this, excl_bit, name))
2167 return 0;
2168#endif
2169 if (verbose(hlock_class(this)))
2170 return 2;
2171
2172 return 1;
2173}
2174
2175static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, 2162static int mark_lock_irq(struct task_struct *curr, struct held_lock *this,
2176 enum lock_usage_bit new_bit) 2163 enum lock_usage_bit new_bit)
2177{ 2164{
@@ -2186,18 +2173,16 @@ static int mark_lock_irq(struct task_struct *curr, struct held_lock *this,
2186 case LOCK_USED_IN_HARDIRQ_READ: 2173 case LOCK_USED_IN_HARDIRQ_READ:
2187 case LOCK_USED_IN_SOFTIRQ_READ: 2174 case LOCK_USED_IN_SOFTIRQ_READ:
2188 case LOCK_USED_IN_RECLAIM_FS_READ: 2175 case LOCK_USED_IN_RECLAIM_FS_READ:
2189 return mark_lock_irq_used_in_read(curr, this, new_bit); 2176 case LOCK_ENABLED_HARDIRQ_READ:
2177 case LOCK_ENABLED_SOFTIRQ_READ:
2178 case LOCK_ENABLED_RECLAIM_FS_READ:
2179 return mark_lock_irq_read(curr, this, new_bit);
2190 2180
2191 case LOCK_ENABLED_HARDIRQ: 2181 case LOCK_ENABLED_HARDIRQ:
2192 case LOCK_ENABLED_SOFTIRQ: 2182 case LOCK_ENABLED_SOFTIRQ:
2193 case LOCK_ENABLED_RECLAIM_FS: 2183 case LOCK_ENABLED_RECLAIM_FS:
2194 return mark_lock_irq_enabled(curr, this, new_bit); 2184 return mark_lock_irq_enabled(curr, this, new_bit);
2195 2185
2196 case LOCK_ENABLED_HARDIRQ_READ:
2197 case LOCK_ENABLED_SOFTIRQ_READ:
2198 case LOCK_ENABLED_RECLAIM_FS_READ:
2199 return mark_lock_irq_enabled_read(curr, this, new_bit);
2200
2201 default: 2186 default:
2202 WARN_ON(1); 2187 WARN_ON(1);
2203 break; 2188 break;