diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-01-22 10:24:44 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-14 17:28:06 -0500 |
commit | 604de3b5b63ebc33a762c44d9c742f235b010346 (patch) | |
tree | 3ba8e39b125103413e9cf278cb832319cc0f8f8e /kernel/lockdep.c | |
parent | 6a6904d3475cc5e4a506b5c3c3684444e22c4cc4 (diff) |
lockdep: simplify the mark_lock_irq() helpers
In order to unify them, take some arguments away
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 | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 0b863c83a774..989a60baf97d 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -2001,12 +2001,38 @@ 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 const char *state_names[] = { | ||
2005 | #define LOCKDEP_STATE(__STATE) \ | ||
2006 | STR(__STATE), | ||
2007 | #include "lockdep_states.h" | ||
2008 | #undef LOCKDEP_STATE | ||
2009 | }; | ||
2010 | |||
2011 | static inline const char *state_name(enum lock_usage_bit bit) | ||
2012 | { | ||
2013 | return state_names[bit >> 2]; | ||
2014 | } | ||
2015 | |||
2016 | static const char *state_rnames[] = { | ||
2017 | #define LOCKDEP_STATE(__STATE) \ | ||
2018 | STR(__STATE)"-READ", | ||
2019 | #include "lockdep_states.h" | ||
2020 | #undef LOCKDEP_STATE | ||
2021 | }; | ||
2022 | |||
2023 | static inline const char *state_rname(enum lock_usage_bit bit) | ||
2024 | { | ||
2025 | return state_rnames[bit >> 2]; | ||
2026 | } | ||
2027 | |||
2004 | static int | 2028 | static int |
2005 | mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, | 2029 | mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, |
2006 | int new_bit, int excl_bit, | 2030 | int new_bit, int excl_bit, |
2007 | const char *name, const char *rname, | ||
2008 | int (*verbose)(struct lock_class *class)) | 2031 | int (*verbose)(struct lock_class *class)) |
2009 | { | 2032 | { |
2033 | const char *name = state_name(new_bit); | ||
2034 | const char *rname = state_rname(new_bit); | ||
2035 | |||
2010 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2036 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2011 | return 0; | 2037 | return 0; |
2012 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | 2038 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) |
@@ -2034,9 +2060,11 @@ mark_lock_irq_used_in(struct task_struct *curr, struct held_lock *this, | |||
2034 | static int | 2060 | static int |
2035 | mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, | 2061 | mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, |
2036 | int new_bit, int excl_bit, | 2062 | int new_bit, int excl_bit, |
2037 | const char *name, const char *rname, | ||
2038 | int (*verbose)(struct lock_class *class)) | 2063 | int (*verbose)(struct lock_class *class)) |
2039 | { | 2064 | { |
2065 | const char *name = state_name(new_bit); | ||
2066 | const char *rname = state_rname(new_bit); | ||
2067 | |||
2040 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2068 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2041 | return 0; | 2069 | return 0; |
2042 | /* | 2070 | /* |
@@ -2054,9 +2082,11 @@ mark_lock_irq_used_in_read(struct task_struct *curr, struct held_lock *this, | |||
2054 | static int | 2082 | static int |
2055 | mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, | 2083 | mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, |
2056 | int new_bit, int excl_bit, | 2084 | int new_bit, int excl_bit, |
2057 | const char *name, const char *rname, | ||
2058 | int (*verbose)(struct lock_class *class)) | 2085 | int (*verbose)(struct lock_class *class)) |
2059 | { | 2086 | { |
2087 | const char *name = state_name(new_bit); | ||
2088 | const char *rname = state_rname(new_bit); | ||
2089 | |||
2060 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2090 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2061 | return 0; | 2091 | return 0; |
2062 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) | 2092 | if (!valid_state(curr, this, new_bit, excl_bit + 1)) |
@@ -2085,9 +2115,11 @@ mark_lock_irq_enabled(struct task_struct *curr, struct held_lock *this, | |||
2085 | static int | 2115 | static int |
2086 | mark_lock_irq_enabled_read(struct task_struct *curr, struct held_lock *this, | 2116 | mark_lock_irq_enabled_read(struct task_struct *curr, struct held_lock *this, |
2087 | int new_bit, int excl_bit, | 2117 | int new_bit, int excl_bit, |
2088 | const char *name, const char *rname, | ||
2089 | int (*verbose)(struct lock_class *class)) | 2118 | int (*verbose)(struct lock_class *class)) |
2090 | { | 2119 | { |
2120 | const char *name = state_name(new_bit); | ||
2121 | const char *rname = state_rname(new_bit); | ||
2122 | |||
2091 | if (!valid_state(curr, this, new_bit, excl_bit)) | 2123 | if (!valid_state(curr, this, new_bit, excl_bit)) |
2092 | return 0; | 2124 | return 0; |
2093 | #if STRICT_READ_CHECKS | 2125 | #if STRICT_READ_CHECKS |
@@ -2113,57 +2145,53 @@ static int mark_lock_irq(struct task_struct *curr, struct held_lock *this, | |||
2113 | case LOCK_USED_IN_HARDIRQ: | 2145 | case LOCK_USED_IN_HARDIRQ: |
2114 | return mark_lock_irq_used_in(curr, this, new_bit, | 2146 | return mark_lock_irq_used_in(curr, this, new_bit, |
2115 | LOCK_ENABLED_HARDIRQ, | 2147 | LOCK_ENABLED_HARDIRQ, |
2116 | "hard", "hard-read", hardirq_verbose); | 2148 | hardirq_verbose); |
2117 | case LOCK_USED_IN_SOFTIRQ: | 2149 | case LOCK_USED_IN_SOFTIRQ: |
2118 | return mark_lock_irq_used_in(curr, this, new_bit, | 2150 | return mark_lock_irq_used_in(curr, this, new_bit, |
2119 | LOCK_ENABLED_SOFTIRQ, | 2151 | LOCK_ENABLED_SOFTIRQ, |
2120 | "soft", "soft-read", softirq_verbose); | 2152 | softirq_verbose); |
2121 | case LOCK_USED_IN_RECLAIM_FS: | 2153 | case LOCK_USED_IN_RECLAIM_FS: |
2122 | return mark_lock_irq_used_in(curr, this, new_bit, | 2154 | return mark_lock_irq_used_in(curr, this, new_bit, |
2123 | LOCK_ENABLED_RECLAIM_FS, | 2155 | LOCK_ENABLED_RECLAIM_FS, |
2124 | "reclaim-fs", "reclaim-fs-read", | ||
2125 | reclaim_verbose); | 2156 | reclaim_verbose); |
2126 | 2157 | ||
2127 | case LOCK_USED_IN_HARDIRQ_READ: | 2158 | case LOCK_USED_IN_HARDIRQ_READ: |
2128 | return mark_lock_irq_used_in_read(curr, this, new_bit, | 2159 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2129 | LOCK_ENABLED_HARDIRQ, | 2160 | LOCK_ENABLED_HARDIRQ, |
2130 | "hard", "hard-read", hardirq_verbose); | 2161 | hardirq_verbose); |
2131 | case LOCK_USED_IN_SOFTIRQ_READ: | 2162 | case LOCK_USED_IN_SOFTIRQ_READ: |
2132 | return mark_lock_irq_used_in_read(curr, this, new_bit, | 2163 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2133 | LOCK_ENABLED_SOFTIRQ, | 2164 | LOCK_ENABLED_SOFTIRQ, |
2134 | "soft", "soft-read", softirq_verbose); | 2165 | softirq_verbose); |
2135 | case LOCK_USED_IN_RECLAIM_FS_READ: | 2166 | case LOCK_USED_IN_RECLAIM_FS_READ: |
2136 | return mark_lock_irq_used_in_read(curr, this, new_bit, | 2167 | return mark_lock_irq_used_in_read(curr, this, new_bit, |
2137 | LOCK_ENABLED_RECLAIM_FS, | 2168 | LOCK_ENABLED_RECLAIM_FS, |
2138 | "reclaim-fs", "reclaim-fs-read", | ||
2139 | reclaim_verbose); | 2169 | reclaim_verbose); |
2140 | 2170 | ||
2141 | case LOCK_ENABLED_HARDIRQ: | 2171 | case LOCK_ENABLED_HARDIRQ: |
2142 | return mark_lock_irq_enabled(curr, this, new_bit, | 2172 | return mark_lock_irq_enabled(curr, this, new_bit, |
2143 | LOCK_USED_IN_HARDIRQ, | 2173 | LOCK_USED_IN_HARDIRQ, |
2144 | "hard", "hard-read", hardirq_verbose); | 2174 | hardirq_verbose); |
2145 | case LOCK_ENABLED_SOFTIRQ: | 2175 | case LOCK_ENABLED_SOFTIRQ: |
2146 | return mark_lock_irq_enabled(curr, this, new_bit, | 2176 | return mark_lock_irq_enabled(curr, this, new_bit, |
2147 | LOCK_USED_IN_SOFTIRQ, | 2177 | LOCK_USED_IN_SOFTIRQ, |
2148 | "soft", "soft-read", softirq_verbose); | 2178 | softirq_verbose); |
2149 | case LOCK_ENABLED_RECLAIM_FS: | 2179 | case LOCK_ENABLED_RECLAIM_FS: |
2150 | return mark_lock_irq_enabled(curr, this, new_bit, | 2180 | return mark_lock_irq_enabled(curr, this, new_bit, |
2151 | LOCK_USED_IN_RECLAIM_FS, | 2181 | LOCK_USED_IN_RECLAIM_FS, |
2152 | "reclaim-fs", "reclaim-fs-read", | ||
2153 | reclaim_verbose); | 2182 | reclaim_verbose); |
2154 | 2183 | ||
2155 | case LOCK_ENABLED_HARDIRQ_READ: | 2184 | case LOCK_ENABLED_HARDIRQ_READ: |
2156 | return mark_lock_irq_enabled_read(curr, this, new_bit, | 2185 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2157 | LOCK_USED_IN_HARDIRQ, | 2186 | LOCK_USED_IN_HARDIRQ, |
2158 | "hard", "hard-read", hardirq_verbose); | 2187 | hardirq_verbose); |
2159 | case LOCK_ENABLED_SOFTIRQ_READ: | 2188 | case LOCK_ENABLED_SOFTIRQ_READ: |
2160 | return mark_lock_irq_enabled_read(curr, this, new_bit, | 2189 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2161 | LOCK_USED_IN_SOFTIRQ, | 2190 | LOCK_USED_IN_SOFTIRQ, |
2162 | "soft", "soft-read", softirq_verbose); | 2191 | softirq_verbose); |
2163 | case LOCK_ENABLED_RECLAIM_FS_READ: | 2192 | case LOCK_ENABLED_RECLAIM_FS_READ: |
2164 | return mark_lock_irq_enabled_read(curr, this, new_bit, | 2193 | return mark_lock_irq_enabled_read(curr, this, new_bit, |
2165 | LOCK_USED_IN_RECLAIM_FS, | 2194 | LOCK_USED_IN_RECLAIM_FS, |
2166 | "reclaim-fs", "reclaim-fs-read", | ||
2167 | reclaim_verbose); | 2195 | reclaim_verbose); |
2168 | 2196 | ||
2169 | default: | 2197 | default: |