diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-01-22 10:09:59 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-14 17:28:08 -0500 |
commit | f989209e2f604730888a6daa3b3ff30ed0c9d7c0 (patch) | |
tree | 80316a7feadef8e13d8c8edb154db1c04736b399 /kernel | |
parent | 604de3b5b63ebc33a762c44d9c742f235b010346 (diff) |
lockdep: further simplify mark_lock_irq() helpers
take away another parameter
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/lockdep.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 989a60baf97d..306d0b823bdb 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -2025,14 +2025,35 @@ static inline const char *state_rname(enum lock_usage_bit bit) | |||
2025 | return state_rnames[bit >> 2]; | 2025 | return state_rnames[bit >> 2]; |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | static int exclusive_bit(int new_bit) | ||
2029 | { | ||
2030 | /* | ||
2031 | * USED_IN | ||
2032 | * USED_IN_READ | ||
2033 | * ENABLED | ||
2034 | * ENABLED_READ | ||
2035 | * | ||
2036 | * bit 0 - write/read | ||
2037 | * bit 1 - used_in/enabled | ||
2038 | * bit 2+ state | ||
2039 | */ | ||
2040 | |||
2041 | int state = new_bit & ~3; | ||
2042 | int dir = new_bit & 2; | ||
2043 | |||
2044 | return state | (dir ^ 2); | ||
2045 | } | ||
2046 | |||
2028 | static int | 2047 | static int |
2029 | mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, | 2048 | mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, |
2030 | int new_bit, int excl_bit, | 2049 | int new_bit, |
2031 | int (*verbose)(struct lock_class *class)) | 2050 | int (*verbose)(struct lock_class *class)) |
2032 | { | 2051 | { |
2033 | const char *name = state_name(new_bit); | 2052 | const char *name = state_name(new_bit); |
2034 | const char *rname = state_rname(new_bit); | 2053 | const char *rname = state_rname(new_bit); |
2035 | 2054 | ||
2055 | int excl_bit = exclusive_bit(new_bit); | ||
2056 | |||
2036 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2057 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2037 | return 0; | 2058 | return 0; |
2038 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | 2059 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) |
@@ -2059,12 +2080,14 @@ mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, | |||
2059 | 2080 | ||
2060 | static int | 2081 | static int |
2061 | mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, | 2082 | mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, |
2062 | int new_bit, int excl_bit, | 2083 | int new_bit, |
2063 | int (*verbose)(struct lock_class *class)) | 2084 | int (*verbose)(struct lock_class *class)) |
2064 | { | 2085 | { |
2065 | const char *name = state_name(new_bit); | 2086 | const char *name = state_name(new_bit); |
2066 | const char *rname = state_rname(new_bit); | 2087 | const char *rname = state_rname(new_bit); |
2067 | 2088 | ||
2089 | int excl_bit = exclusive_bit(new_bit); | ||
2090 | |||
2068 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2091 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2069 | return 0; | 2092 | return 0; |
2070 | /* | 2093 | /* |
@@ -2081,12 +2104,14 @@ mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, | |||
2081 | 2104 | ||
2082 | static int | 2105 | static int |
2083 | mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, | 2106 | mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, |
2084 | int new_bit, int excl_bit, | 2107 | int new_bit, |
2085 | int (*verbose)(struct lock_class *class)) | 2108 | int (*verbose)(struct lock_class *class)) |
2086 | { | 2109 | { |
2087 | const char *name = state_name(new_bit); | 2110 | const char *name = state_name(new_bit); |
2088 | const char *rname = state_rname(new_bit); | 2111 | const char *rname = state_rname(new_bit); |
2089 | 2112 | ||
2113 | int excl_bit = exclusive_bit(new_bit); | ||
2114 | |||
2090 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2115 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2091 | return 0; | 2116 | return 0; |
2092 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | 2117 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) |
@@ -2114,12 +2139,14 @@ mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, | |||
2114 | 2139 | ||
2115 | static int | 2140 | static int |
2116 | mark_lock_irq_enabled_read(struct task_struct *curr, struct held_lock *this, | 2141 | mark_lock_irq_enabled_read(struct task_struct *curr, struct held_lock *this, |
2117 | int new_bit, int excl_bit, | 2142 | int new_bit, |
2118 | int (*verbose)(struct lock_class *class)) | 2143 | int (*verbose)(struct lock_class *class)) |
2119 | { | 2144 | { |
2120 | const char *name = state_name(new_bit); | 2145 | const char *name = state_name(new_bit); |
2121 | const char *rname = state_rname(new_bit); | 2146 | const char *rname = state_rname(new_bit); |
2122 | 2147 | ||
2148 | int excl_bit = exclusive_bit(new_bit); | ||
2149 | |||
2123 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2150 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2124 | return 0; | 2151 | return 0; |
2125 | #if STRICT_READ_CHECKS | 2152 | #if STRICT_READ_CHECKS |
@@ -2144,54 +2171,42 @@ static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, | |||
2144 | switch(new_bit) { | 2171 | switch(new_bit) { |
2145 | case LOCK_USED_IN_HARDIRQ: | 2172 | case LOCK_USED_IN_HARDIRQ: |
2146 | return mark_lock_irq_used_in(curr, this, new_bit, | 2173 | return mark_lock_irq_used_in(curr, this, new_bit, |
2147 | LOCK_ENABLED_HARDIRQ, | ||
2148 | hardirq_verbose); | 2174 | hardirq_verbose); |
2149 | case LOCK_USED_IN_SOFTIRQ: | 2175 | case LOCK_USED_IN_SOFTIRQ: |
2150 | return mark_lock_irq_used_in(curr, this, new_bit, | 2176 | return mark_lock_irq_used_in(curr, this, new_bit, |
2151 | LOCK_ENABLED_SOFTIRQ, | ||
2152 | softirq_verbose); | 2177 | softirq_verbose); |
2153 | case LOCK_USED_IN_RECLAIM_FS: | 2178 | case LOCK_USED_IN_RECLAIM_FS: |
2154 | return mark_lock_irq_used_in(curr, this, new_bit, | 2179 | return mark_lock_irq_used_in(curr, this, new_bit, |
2155 | LOCK_ENABLED_RECLAIM_FS, | ||
2156 | reclaim_verbose); | 2180 | reclaim_verbose); |
2157 | 2181 | ||
2158 | case LOCK_USED_IN_HARDIRQ_READ: | 2182 | case LOCK_USED_IN_HARDIRQ_READ: |
2159 | return mark_lock_irq_used_in_read(curr, this, new_bit, | 2183 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2160 | LOCK_ENABLED_HARDIRQ, | ||
2161 | hardirq_verbose); | 2184 | hardirq_verbose); |
2162 | case LOCK_USED_IN_SOFTIRQ_READ: | 2185 | case LOCK_USED_IN_SOFTIRQ_READ: |
2163 | return mark_lock_irq_used_in_read(curr, this, new_bit, | 2186 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2164 | LOCK_ENABLED_SOFTIRQ, | ||
2165 | softirq_verbose); | 2187 | softirq_verbose); |
2166 | case LOCK_USED_IN_RECLAIM_FS_READ: | 2188 | case LOCK_USED_IN_RECLAIM_FS_READ: |
2167 | return mark_lock_irq_used_in_read(curr, this, new_bit, | 2189 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2168 | LOCK_ENABLED_RECLAIM_FS, | ||
2169 | reclaim_verbose); | 2190 | reclaim_verbose); |
2170 | 2191 | ||
2171 | case LOCK_ENABLED_HARDIRQ: | 2192 | case LOCK_ENABLED_HARDIRQ: |
2172 | return mark_lock_irq_enabled(curr, this, new_bit, | 2193 | return mark_lock_irq_enabled(curr, this, new_bit, |
2173 | LOCK_USED_IN_HARDIRQ, | ||
2174 | hardirq_verbose); | 2194 | hardirq_verbose); |
2175 | case LOCK_ENABLED_SOFTIRQ: | 2195 | case LOCK_ENABLED_SOFTIRQ: |
2176 | return mark_lock_irq_enabled(curr, this, new_bit, | 2196 | return mark_lock_irq_enabled(curr, this, new_bit, |
2177 | LOCK_USED_IN_SOFTIRQ, | ||
2178 | softirq_verbose); | 2197 | softirq_verbose); |
2179 | case LOCK_ENABLED_RECLAIM_FS: | 2198 | case LOCK_ENABLED_RECLAIM_FS: |
2180 | return mark_lock_irq_enabled(curr, this, new_bit, | 2199 | return mark_lock_irq_enabled(curr, this, new_bit, |
2181 | LOCK_USED_IN_RECLAIM_FS, | ||
2182 | reclaim_verbose); | 2200 | reclaim_verbose); |
2183 | 2201 | ||
2184 | case LOCK_ENABLED_HARDIRQ_READ: | 2202 | case LOCK_ENABLED_HARDIRQ_READ: |
2185 | return mark_lock_irq_enabled_read(curr, this, new_bit, | 2203 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2186 | LOCK_USED_IN_HARDIRQ, | ||
2187 | hardirq_verbose); | 2204 | hardirq_verbose); |
2188 | case LOCK_ENABLED_SOFTIRQ_READ: | 2205 | case LOCK_ENABLED_SOFTIRQ_READ: |
2189 | return mark_lock_irq_enabled_read(curr, this, new_bit, | 2206 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2190 | LOCK_USED_IN_SOFTIRQ, | ||
2191 | softirq_verbose); | 2207 | softirq_verbose); |
2192 | case LOCK_ENABLED_RECLAIM_FS_READ: | 2208 | case LOCK_ENABLED_RECLAIM_FS_READ: |
2193 | return mark_lock_irq_enabled_read(curr, this, new_bit, | 2209 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2194 | LOCK_USED_IN_RECLAIM_FS, | ||
2195 | reclaim_verbose); | 2210 | reclaim_verbose); |
2196 | 2211 | ||
2197 | default: | 2212 | default: |