diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/lockdep.c | 86 |
1 files changed, 8 insertions, 78 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 1ba52e68355a..000d53a2da32 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -2061,13 +2061,13 @@ typedef int (*check_usage_f)(struct task_struct *, struct held_lock *, | |||
2061 | enum lock_usage_bit bit, const char *name); | 2061 | enum lock_usage_bit bit, const char *name); |
2062 | 2062 | ||
2063 | static int | 2063 | static int |
2064 | mark_lock_irq_write(struct task_struct *curr, struct held_lock *this, | 2064 | mark_lock_irq(struct task_struct *curr, struct held_lock *this, int new_bit) |
2065 | int new_bit) | ||
2066 | { | 2065 | { |
2067 | const char *name = state_name(new_bit); | 2066 | const char *name = state_name(new_bit); |
2068 | const char *rname = state_rname(new_bit); | 2067 | const char *rname = state_rname(new_bit); |
2069 | 2068 | ||
2070 | int excl_bit = exclusive_bit(new_bit); | 2069 | int excl_bit = exclusive_bit(new_bit); |
2070 | int read = new_bit & 1; | ||
2071 | int dir = new_bit & 2; | 2071 | int dir = new_bit & 2; |
2072 | 2072 | ||
2073 | check_usage_f usage = dir ? | 2073 | check_usage_f usage = dir ? |
@@ -2075,57 +2075,17 @@ mark_lock_irq_write(struct task_struct *curr, struct held_lock *this, | |||
2075 | 2075 | ||
2076 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2076 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2077 | return 0; | 2077 | return 0; |
2078 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | ||
2079 | return 0; | ||
2080 | 2078 | ||
2081 | /* | 2079 | if (!read && !valid_state(curr, this, new_bit, excl_bit + 1)) |
2082 | * just marked it hardirq-safe, check that this lock | ||
2083 | * took no hardirq-unsafe lock in the past: | ||
2084 | */ | ||
2085 | if (!usage(curr, this, excl_bit, name)) | ||
2086 | return 0; | ||
2087 | #if STRICT_READ_CHECKS | ||
2088 | /* | ||
2089 | * just marked it hardirq-safe, check that this lock | ||
2090 | * took no hardirq-unsafe-read lock in the past: | ||
2091 | */ | ||
2092 | if (!usage(curr, this, excl_bit + 1, rname)) | ||
2093 | return 0; | 2080 | return 0; |
2094 | #endif | ||
2095 | if (state_verbose(new_bit, hlock_class(this))) | ||
2096 | return 2; | ||
2097 | |||
2098 | return 1; | ||
2099 | } | ||
2100 | |||
2101 | static int | ||
2102 | mark_lock_irq_read(struct task_struct *curr, struct held_lock *this, | ||
2103 | int new_bit) | ||
2104 | { | ||
2105 | const char *name = state_name(new_bit); | ||
2106 | const char *rname = state_rname(new_bit); | ||
2107 | |||
2108 | int excl_bit = exclusive_bit(new_bit); | ||
2109 | int dir = new_bit & 2; | ||
2110 | 2081 | ||
2111 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2082 | if ((!read || (!dir || STRICT_READ_CHECKS)) && |
2083 | !usage(curr, this, excl_bit, name)) | ||
2112 | return 0; | 2084 | return 0; |
2113 | 2085 | ||
2114 | if (!dir) { | 2086 | if ((!read && STRICT_READ_CHECKS) && |
2115 | /* | 2087 | !usage(curr, this, excl_bit + 1, rname)) |
2116 | * just marked it hardirq-read-safe, check that this lock | 2088 | return 0; |
2117 | * took no hardirq-unsafe lock in the past: | ||
2118 | */ | ||
2119 | if (!check_usage_forwards(curr, this, excl_bit, name)) | ||
2120 | return 0; | ||
2121 | } else if (STRICT_READ_CHECKS) { | ||
2122 | /* | ||
2123 | * just marked it hardirq-read-unsafe, check that no | ||
2124 | * hardirq-safe lock in the system ever took it in the past: | ||
2125 | */ | ||
2126 | if (!check_usage_backwards(curr, this, excl_bit, name)) | ||
2127 | return 0; | ||
2128 | } | ||
2129 | 2089 | ||
2130 | if (state_verbose(new_bit, hlock_class(this))) | 2090 | if (state_verbose(new_bit, hlock_class(this))) |
2131 | return 2; | 2091 | return 2; |
@@ -2133,36 +2093,6 @@ mark_lock_irq_read(struct task_struct *curr, struct held_lock *this, | |||
2133 | return 1; | 2093 | return 1; |
2134 | } | 2094 | } |
2135 | 2095 | ||
2136 | static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, | ||
2137 | enum lock_usage_bit new_bit) | ||
2138 | { | ||
2139 | int ret = 1; | ||
2140 | |||
2141 | switch(new_bit) { | ||
2142 | case LOCK_USED_IN_HARDIRQ: | ||
2143 | case LOCK_USED_IN_SOFTIRQ: | ||
2144 | case LOCK_USED_IN_RECLAIM_FS: | ||
2145 | case LOCK_ENABLED_HARDIRQ: | ||
2146 | case LOCK_ENABLED_SOFTIRQ: | ||
2147 | case LOCK_ENABLED_RECLAIM_FS: | ||
2148 | return mark_lock_irq_write(curr, this, new_bit); | ||
2149 | |||
2150 | case LOCK_USED_IN_HARDIRQ_READ: | ||
2151 | case LOCK_USED_IN_SOFTIRQ_READ: | ||
2152 | case LOCK_USED_IN_RECLAIM_FS_READ: | ||
2153 | case LOCK_ENABLED_HARDIRQ_READ: | ||
2154 | case LOCK_ENABLED_SOFTIRQ_READ: | ||
2155 | case LOCK_ENABLED_RECLAIM_FS_READ: | ||
2156 | return mark_lock_irq_read(curr, this, new_bit); | ||
2157 | |||
2158 | default: | ||
2159 | WARN_ON(1); | ||
2160 | break; | ||
2161 | } | ||
2162 | |||
2163 | return ret; | ||
2164 | } | ||
2165 | |||
2166 | enum mark_type { | 2096 | enum mark_type { |
2167 | #define LOCKDEP_STATE(__STATE) __STATE, | 2097 | #define LOCKDEP_STATE(__STATE) __STATE, |
2168 | #include "lockdep_states.h" | 2098 | #include "lockdep_states.h" |