diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-01-22 10:07:44 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-14 17:28:04 -0500 |
commit | 6a6904d3475cc5e4a506b5c3c3684444e22c4cc4 (patch) | |
tree | 6bf546577ee9441399161a67188c03151ff63f6a /kernel/lockdep.c | |
parent | fabe9c42c6328de314d811887b4752eb3d202291 (diff) |
lockdep: split up mark_lock_irq()
split mark_lock_irq() into 4 simple helper functions
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.c | 372 |
1 files changed, 147 insertions, 225 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index d31f7f836a0d..0b863c83a774 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -2001,6 +2001,109 @@ static int reclaim_verbose(struct lock_class *class) | |||
2001 | 2001 | ||
2002 | #define STRICT_READ_CHECKS 1 | 2002 | #define STRICT_READ_CHECKS 1 |
2003 | 2003 | ||
2004 | static int | ||
2005 | mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, | ||
2006 | int new_bit, int excl_bit, | ||
2007 | const char *name, const char *rname, | ||
2008 | int (*verbose)(struct lock_class *class)) | ||
2009 | { | ||
2010 | if (!valid_state(curr, this, new_bit, excl_bit)) | ||
2011 | return 0; | ||
2012 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | ||
2013 | return 0; | ||
2014 | /* | ||
2015 | * just marked it hardirq-safe, check that this lock | ||
2016 | * took no hardirq-unsafe lock in the past: | ||
2017 | */ | ||
2018 | if (!check_usage_forwards(curr, this, excl_bit, name)) | ||
2019 | return 0; | ||
2020 | #if STRICT_READ_CHECKS | ||
2021 | /* | ||
2022 | * just marked it hardirq-safe, check that this lock | ||
2023 | * took no hardirq-unsafe-read lock in the past: | ||
2024 | */ | ||
2025 | if (!check_usage_forwards(curr, this, excl_bit + 1, rname)) | ||
2026 | return 0; | ||
2027 | #endif | ||
2028 | if (verbose(hlock_class(this))) | ||
2029 | return 2; | ||
2030 | |||
2031 | return 1; | ||
2032 | } | ||
2033 | |||
2034 | static int | ||
2035 | mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, | ||
2036 | int new_bit, int excl_bit, | ||
2037 | const char *name, const char *rname, | ||
2038 | int (*verbose)(struct lock_class *class)) | ||
2039 | { | ||
2040 | if (!valid_state(curr, this, new_bit, excl_bit)) | ||
2041 | return 0; | ||
2042 | /* | ||
2043 | * just marked it hardirq-read-safe, check that this lock | ||
2044 | * took no hardirq-unsafe lock in the past: | ||
2045 | */ | ||
2046 | if (!check_usage_forwards(curr, this, excl_bit, name)) | ||
2047 | return 0; | ||
2048 | if (verbose(hlock_class(this))) | ||
2049 | return 2; | ||
2050 | |||
2051 | return 1; | ||
2052 | } | ||
2053 | |||
2054 | static int | ||
2055 | mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, | ||
2056 | int new_bit, int excl_bit, | ||
2057 | const char *name, const char *rname, | ||
2058 | int (*verbose)(struct lock_class *class)) | ||
2059 | { | ||
2060 | if (!valid_state(curr, this, new_bit, excl_bit)) | ||
2061 | return 0; | ||
2062 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | ||
2063 | return 0; | ||
2064 | /* | ||
2065 | * just marked it hardirq-unsafe, check that no hardirq-safe | ||
2066 | * lock in the system ever took it in the past: | ||
2067 | */ | ||
2068 | if (!check_usage_backwards(curr, this, excl_bit, name)) | ||
2069 | return 0; | ||
2070 | #if STRICT_READ_CHECKS | ||
2071 | /* | ||
2072 | * just marked it hardirq-unsafe, check that no | ||
2073 | * hardirq-safe-read lock in the system ever took | ||
2074 | * it in the past: | ||
2075 | */ | ||
2076 | if (!check_usage_backwards(curr, this, excl_bit + 1, rname)) | ||
2077 | return 0; | ||
2078 | #endif | ||
2079 | if (verbose(hlock_class(this))) | ||
2080 | return 2; | ||
2081 | |||
2082 | return 1; | ||
2083 | } | ||
2084 | |||
2085 | static int | ||
2086 | mark_lock_irq_enabled_read(struct task_struct *curr, struct held_lock *this, | ||
2087 | int new_bit, int excl_bit, | ||
2088 | const char *name, const char *rname, | ||
2089 | int (*verbose)(struct lock_class *class)) | ||
2090 | { | ||
2091 | if (!valid_state(curr, this, new_bit, excl_bit)) | ||
2092 | return 0; | ||
2093 | #if STRICT_READ_CHECKS | ||
2094 | /* | ||
2095 | * just marked it hardirq-read-unsafe, check that no | ||
2096 | * hardirq-safe lock in the system ever took it in the past: | ||
2097 | */ | ||
2098 | if (!check_usage_backwards(curr, this, excl_bit, name)) | ||
2099 | return 0; | ||
2100 | #endif | ||
2101 | if (verbose(hlock_class(this))) | ||
2102 | return 2; | ||
2103 | |||
2104 | return 1; | ||
2105 | } | ||
2106 | |||
2004 | static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, | 2107 | static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, |
2005 | enum lock_usage_bit new_bit) | 2108 | enum lock_usage_bit new_bit) |
2006 | { | 2109 | { |
@@ -2008,242 +2111,61 @@ static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, | |||
2008 | 2111 | ||
2009 | switch(new_bit) { | 2112 | switch(new_bit) { |
2010 | case LOCK_USED_IN_HARDIRQ: | 2113 | case LOCK_USED_IN_HARDIRQ: |
2011 | if (!valid_state(curr, this, new_bit, LOCK_ENABLED_HARDIRQ)) | 2114 | return mark_lock_irq_used_in(curr, this, new_bit, |
2012 | return 0; | 2115 | LOCK_ENABLED_HARDIRQ, |
2013 | if (!valid_state(curr, this, new_bit, | 2116 | "hard", "hard-read", hardirq_verbose); |
2014 | LOCK_ENABLED_HARDIRQ_READ)) | ||
2015 | return 0; | ||
2016 | /* | ||
2017 | * just marked it hardirq-safe, check that this lock | ||
2018 | * took no hardirq-unsafe lock in the past: | ||
2019 | */ | ||
2020 | if (!check_usage_forwards(curr, this, | ||
2021 | LOCK_ENABLED_HARDIRQ, "hard")) | ||
2022 | return 0; | ||
2023 | #if STRICT_READ_CHECKS | ||
2024 | /* | ||
2025 | * just marked it hardirq-safe, check that this lock | ||
2026 | * took no hardirq-unsafe-read lock in the past: | ||
2027 | */ | ||
2028 | if (!check_usage_forwards(curr, this, | ||
2029 | LOCK_ENABLED_HARDIRQ_READ, "hard-read")) | ||
2030 | return 0; | ||
2031 | #endif | ||
2032 | if (hardirq_verbose(hlock_class(this))) | ||
2033 | ret = 2; | ||
2034 | break; | ||
2035 | case LOCK_USED_IN_SOFTIRQ: | 2117 | case LOCK_USED_IN_SOFTIRQ: |
2036 | if (!valid_state(curr, this, new_bit, LOCK_ENABLED_SOFTIRQ)) | 2118 | return mark_lock_irq_used_in(curr, this, new_bit, |
2037 | return 0; | 2119 | LOCK_ENABLED_SOFTIRQ, |
2038 | if (!valid_state(curr, this, new_bit, | 2120 | "soft", "soft-read", softirq_verbose); |
2039 | LOCK_ENABLED_SOFTIRQ_READ)) | ||
2040 | return 0; | ||
2041 | /* | ||
2042 | * just marked it softirq-safe, check that this lock | ||
2043 | * took no softirq-unsafe lock in the past: | ||
2044 | */ | ||
2045 | if (!check_usage_forwards(curr, this, | ||
2046 | LOCK_ENABLED_SOFTIRQ, "soft")) | ||
2047 | return 0; | ||
2048 | #if STRICT_READ_CHECKS | ||
2049 | /* | ||
2050 | * just marked it softirq-safe, check that this lock | ||
2051 | * took no softirq-unsafe-read lock in the past: | ||
2052 | */ | ||
2053 | if (!check_usage_forwards(curr, this, | ||
2054 | LOCK_ENABLED_SOFTIRQ_READ, "soft-read")) | ||
2055 | return 0; | ||
2056 | #endif | ||
2057 | if (softirq_verbose(hlock_class(this))) | ||
2058 | ret = 2; | ||
2059 | break; | ||
2060 | case LOCK_USED_IN_RECLAIM_FS: | 2121 | case LOCK_USED_IN_RECLAIM_FS: |
2061 | if (!valid_state(curr, this, new_bit, LOCK_ENABLED_RECLAIM_FS)) | 2122 | return mark_lock_irq_used_in(curr, this, new_bit, |
2062 | return 0; | 2123 | LOCK_ENABLED_RECLAIM_FS, |
2063 | if (!valid_state(curr, this, new_bit, | 2124 | "reclaim-fs", "reclaim-fs-read", |
2064 | LOCK_ENABLED_RECLAIM_FS_READ)) | 2125 | reclaim_verbose); |
2065 | return 0; | 2126 | |
2066 | /* | ||
2067 | * just marked it reclaim-fs-safe, check that this lock | ||
2068 | * took no reclaim-fs-unsafe lock in the past: | ||
2069 | */ | ||
2070 | if (!check_usage_forwards(curr, this, | ||
2071 | LOCK_ENABLED_RECLAIM_FS, "reclaim-fs")) | ||
2072 | return 0; | ||
2073 | #if STRICT_READ_CHECKS | ||
2074 | /* | ||
2075 | * just marked it reclaim-fs-safe, check that this lock | ||
2076 | * took no reclaim-fs-unsafe-read lock in the past: | ||
2077 | */ | ||
2078 | if (!check_usage_forwards(curr, this, | ||
2079 | LOCK_ENABLED_RECLAIM_FS_READ, "reclaim-fs-read")) | ||
2080 | return 0; | ||
2081 | #endif | ||
2082 | if (reclaim_verbose(hlock_class(this))) | ||
2083 | ret = 2; | ||
2084 | break; | ||
2085 | case LOCK_USED_IN_HARDIRQ_READ: | 2127 | case LOCK_USED_IN_HARDIRQ_READ: |
2086 | if (!valid_state(curr, this, new_bit, LOCK_ENABLED_HARDIRQ)) | 2128 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2087 | return 0; | 2129 | LOCK_ENABLED_HARDIRQ, |
2088 | /* | 2130 | "hard", "hard-read", hardirq_verbose); |
2089 | * just marked it hardirq-read-safe, check that this lock | ||
2090 | * took no hardirq-unsafe lock in the past: | ||
2091 | */ | ||
2092 | if (!check_usage_forwards(curr, this, | ||
2093 | LOCK_ENABLED_HARDIRQ, "hard")) | ||
2094 | return 0; | ||
2095 | if (hardirq_verbose(hlock_class(this))) | ||
2096 | ret = 2; | ||
2097 | break; | ||
2098 | case LOCK_USED_IN_SOFTIRQ_READ: | 2131 | case LOCK_USED_IN_SOFTIRQ_READ: |
2099 | if (!valid_state(curr, this, new_bit, LOCK_ENABLED_SOFTIRQ)) | 2132 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2100 | return 0; | 2133 | LOCK_ENABLED_SOFTIRQ, |
2101 | /* | 2134 | "soft", "soft-read", softirq_verbose); |
2102 | * just marked it softirq-read-safe, check that this lock | ||
2103 | * took no softirq-unsafe lock in the past: | ||
2104 | */ | ||
2105 | if (!check_usage_forwards(curr, this, | ||
2106 | LOCK_ENABLED_SOFTIRQ, "soft")) | ||
2107 | return 0; | ||
2108 | if (softirq_verbose(hlock_class(this))) | ||
2109 | ret = 2; | ||
2110 | break; | ||
2111 | case LOCK_USED_IN_RECLAIM_FS_READ: | 2135 | case LOCK_USED_IN_RECLAIM_FS_READ: |
2112 | if (!valid_state(curr, this, new_bit, LOCK_ENABLED_RECLAIM_FS)) | 2136 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2113 | return 0; | 2137 | LOCK_ENABLED_RECLAIM_FS, |
2114 | /* | 2138 | "reclaim-fs", "reclaim-fs-read", |
2115 | * just marked it reclaim-fs-read-safe, check that this lock | 2139 | reclaim_verbose); |
2116 | * took no reclaim-fs-unsafe lock in the past: | 2140 | |
2117 | */ | ||
2118 | if (!check_usage_forwards(curr, this, | ||
2119 | LOCK_ENABLED_RECLAIM_FS, "reclaim-fs")) | ||
2120 | return 0; | ||
2121 | if (reclaim_verbose(hlock_class(this))) | ||
2122 | ret = 2; | ||
2123 | break; | ||
2124 | case LOCK_ENABLED_HARDIRQ: | 2141 | case LOCK_ENABLED_HARDIRQ: |
2125 | if (!valid_state(curr, this, new_bit, LOCK_USED_IN_HARDIRQ)) | 2142 | return mark_lock_irq_enabled(curr, this, new_bit, |
2126 | return 0; | 2143 | LOCK_USED_IN_HARDIRQ, |
2127 | if (!valid_state(curr, this, new_bit, | 2144 | "hard", "hard-read", hardirq_verbose); |
2128 | LOCK_USED_IN_HARDIRQ_READ)) | ||
2129 | return 0; | ||
2130 | /* | ||
2131 | * just marked it hardirq-unsafe, check that no hardirq-safe | ||
2132 | * lock in the system ever took it in the past: | ||
2133 | */ | ||
2134 | if (!check_usage_backwards(curr, this, | ||
2135 | LOCK_USED_IN_HARDIRQ, "hard")) | ||
2136 | return 0; | ||
2137 | #if STRICT_READ_CHECKS | ||
2138 | /* | ||
2139 | * just marked it hardirq-unsafe, check that no | ||
2140 | * hardirq-safe-read lock in the system ever took | ||
2141 | * it in the past: | ||
2142 | */ | ||
2143 | if (!check_usage_backwards(curr, this, | ||
2144 | LOCK_USED_IN_HARDIRQ_READ, "hard-read")) | ||
2145 | return 0; | ||
2146 | #endif | ||
2147 | if (hardirq_verbose(hlock_class(this))) | ||
2148 | ret = 2; | ||
2149 | break; | ||
2150 | case LOCK_ENABLED_SOFTIRQ: | 2145 | case LOCK_ENABLED_SOFTIRQ: |
2151 | if (!valid_state(curr, this, new_bit, LOCK_USED_IN_SOFTIRQ)) | 2146 | return mark_lock_irq_enabled(curr, this, new_bit, |
2152 | return 0; | 2147 | LOCK_USED_IN_SOFTIRQ, |
2153 | if (!valid_state(curr, this, new_bit, | 2148 | "soft", "soft-read", softirq_verbose); |
2154 | LOCK_USED_IN_SOFTIRQ_READ)) | ||
2155 | return 0; | ||
2156 | /* | ||
2157 | * just marked it softirq-unsafe, check that no softirq-safe | ||
2158 | * lock in the system ever took it in the past: | ||
2159 | */ | ||
2160 | if (!check_usage_backwards(curr, this, | ||
2161 | LOCK_USED_IN_SOFTIRQ, "soft")) | ||
2162 | return 0; | ||
2163 | #if STRICT_READ_CHECKS | ||
2164 | /* | ||
2165 | * just marked it softirq-unsafe, check that no | ||
2166 | * softirq-safe-read lock in the system ever took | ||
2167 | * it in the past: | ||
2168 | */ | ||
2169 | if (!check_usage_backwards(curr, this, | ||
2170 | LOCK_USED_IN_SOFTIRQ_READ, "soft-read")) | ||
2171 | return 0; | ||
2172 | #endif | ||
2173 | if (softirq_verbose(hlock_class(this))) | ||
2174 | ret = 2; | ||
2175 | break; | ||
2176 | case LOCK_ENABLED_RECLAIM_FS: | 2149 | case LOCK_ENABLED_RECLAIM_FS: |
2177 | if (!valid_state(curr, this, new_bit, LOCK_USED_IN_RECLAIM_FS)) | 2150 | return mark_lock_irq_enabled(curr, this, new_bit, |
2178 | return 0; | 2151 | LOCK_USED_IN_RECLAIM_FS, |
2179 | if (!valid_state(curr, this, new_bit, | 2152 | "reclaim-fs", "reclaim-fs-read", |
2180 | LOCK_USED_IN_RECLAIM_FS_READ)) | 2153 | reclaim_verbose); |
2181 | return 0; | 2154 | |
2182 | /* | ||
2183 | * just marked it reclaim-fs-unsafe, check that no reclaim-fs-safe | ||
2184 | * lock in the system ever took it in the past: | ||
2185 | */ | ||
2186 | if (!check_usage_backwards(curr, this, | ||
2187 | LOCK_USED_IN_RECLAIM_FS, "reclaim-fs")) | ||
2188 | return 0; | ||
2189 | #if STRICT_READ_CHECKS | ||
2190 | /* | ||
2191 | * just marked it softirq-unsafe, check that no | ||
2192 | * softirq-safe-read lock in the system ever took | ||
2193 | * it in the past: | ||
2194 | */ | ||
2195 | if (!check_usage_backwards(curr, this, | ||
2196 | LOCK_USED_IN_RECLAIM_FS_READ, "reclaim-fs-read")) | ||
2197 | return 0; | ||
2198 | #endif | ||
2199 | if (reclaim_verbose(hlock_class(this))) | ||
2200 | ret = 2; | ||
2201 | break; | ||
2202 | case LOCK_ENABLED_HARDIRQ_READ: | 2155 | case LOCK_ENABLED_HARDIRQ_READ: |
2203 | if (!valid_state(curr, this, new_bit, LOCK_USED_IN_HARDIRQ)) | 2156 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2204 | return 0; | 2157 | LOCK_USED_IN_HARDIRQ, |
2205 | #if STRICT_READ_CHECKS | 2158 | "hard", "hard-read", hardirq_verbose); |
2206 | /* | ||
2207 | * just marked it hardirq-read-unsafe, check that no | ||
2208 | * hardirq-safe lock in the system ever took it in the past: | ||
2209 | */ | ||
2210 | if (!check_usage_backwards(curr, this, | ||
2211 | LOCK_USED_IN_HARDIRQ, "hard")) | ||
2212 | return 0; | ||
2213 | #endif | ||
2214 | if (hardirq_verbose(hlock_class(this))) | ||
2215 | ret = 2; | ||
2216 | break; | ||
2217 | case LOCK_ENABLED_SOFTIRQ_READ: | 2159 | case LOCK_ENABLED_SOFTIRQ_READ: |
2218 | if (!valid_state(curr, this, new_bit, LOCK_USED_IN_SOFTIRQ)) | 2160 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2219 | return 0; | 2161 | LOCK_USED_IN_SOFTIRQ, |
2220 | #if STRICT_READ_CHECKS | 2162 | "soft", "soft-read", softirq_verbose); |
2221 | /* | ||
2222 | * just marked it softirq-read-unsafe, check that no | ||
2223 | * softirq-safe lock in the system ever took it in the past: | ||
2224 | */ | ||
2225 | if (!check_usage_backwards(curr, this, | ||
2226 | LOCK_USED_IN_SOFTIRQ, "soft")) | ||
2227 | return 0; | ||
2228 | #endif | ||
2229 | if (softirq_verbose(hlock_class(this))) | ||
2230 | ret = 2; | ||
2231 | break; | ||
2232 | case LOCK_ENABLED_RECLAIM_FS_READ: | 2163 | case LOCK_ENABLED_RECLAIM_FS_READ: |
2233 | if (!valid_state(curr, this, new_bit, LOCK_USED_IN_RECLAIM_FS)) | 2164 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2234 | return 0; | 2165 | LOCK_USED_IN_RECLAIM_FS, |
2235 | #if STRICT_READ_CHECKS | 2166 | "reclaim-fs", "reclaim-fs-read", |
2236 | /* | 2167 | reclaim_verbose); |
2237 | * just marked it reclaim-fs-read-unsafe, check that no | 2168 | |
2238 | * reclaim-fs-safe lock in the system ever took it in the past: | ||
2239 | */ | ||
2240 | if (!check_usage_backwards(curr, this, | ||
2241 | LOCK_USED_IN_RECLAIM_FS, "reclaim-fs")) | ||
2242 | return 0; | ||
2243 | #endif | ||
2244 | if (reclaim_verbose(hlock_class(this))) | ||
2245 | ret = 2; | ||
2246 | break; | ||
2247 | default: | 2169 | default: |
2248 | WARN_ON(1); | 2170 | WARN_ON(1); |
2249 | break; | 2171 | break; |