diff options
| author | Mark Rutland <mark.rutland@arm.com> | 2018-09-04 06:48:26 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-11-01 06:00:46 -0400 |
| commit | 9fa45070a2e59a871e1cd3370173369f3a4f61e2 (patch) | |
| tree | bf28d28903a0d5077452edceef78f260c2111ccb /include/linux/atomic.h | |
| parent | ace9bad4df2684f31cbfe8c4ce7a0f5d92b27925 (diff) | |
locking/atomics: Switch to generated fallbacks
As a step to ensuring the atomic* APIs are consistent, switch to fallbacks
generated by gen-atomic-fallback.sh.
These are checked in rather than generated with Kbuild, since:
* This allows inspection of the atomics with git grep and ctags on a
pristine tree, which Linus strongly prefers being able to do.
* The fallbacks are not affected by machine details or configuration
options, so it is not necessary to regenerate them to take these into
account.
* These are included by files required *very* early in the build process
(e.g. for generating bounds.h), and we'd rather not complicate the
top-level Kbuild file with dependencies.
The new fallback header should be equivalent to the old fallbacks in
<linux/atomic.h>, but:
* It is formatted a little differently due to scripting ensuring things
are more regular than they used to be.
* Fallbacks are now expanded in-place as static inline functions rather
than macros.
* The prototypes for fallbacks are arragned consistently with the return
type on a separate line to try to keep to a sensible line length.
There should be no functional change as a result of this patch.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: catalin.marinas@arm.com
Cc: linuxdrivers@attotech.com
Cc: dvyukov@google.com
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: arnd@arndb.de
Cc: aryabinin@virtuozzo.com
Cc: glider@google.com
Link: http://lkml.kernel.org/r/20180904104830.2975-3-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/atomic.h')
| -rw-r--r-- | include/linux/atomic.h | 1241 |
1 files changed, 1 insertions, 1240 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 1e8e88bdaf09..4c0d009a46f0 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h | |||
| @@ -25,14 +25,6 @@ | |||
| 25 | * See Documentation/memory-barriers.txt for ACQUIRE/RELEASE definitions. | 25 | * See Documentation/memory-barriers.txt for ACQUIRE/RELEASE definitions. |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | #ifndef atomic_read_acquire | ||
| 29 | #define atomic_read_acquire(v) smp_load_acquire(&(v)->counter) | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #ifndef atomic_set_release | ||
| 33 | #define atomic_set_release(v, i) smp_store_release(&(v)->counter, (i)) | ||
| 34 | #endif | ||
| 35 | |||
| 36 | /* | 28 | /* |
| 37 | * The idea here is to build acquire/release variants by adding explicit | 29 | * The idea here is to build acquire/release variants by adding explicit |
| 38 | * barriers on top of the relaxed variant. In the case where the relaxed | 30 | * barriers on top of the relaxed variant. In the case where the relaxed |
| @@ -79,1238 +71,7 @@ | |||
| 79 | __ret; \ | 71 | __ret; \ |
| 80 | }) | 72 | }) |
| 81 | 73 | ||
| 82 | /* atomic_add_return_relaxed */ | 74 | #include <linux/atomic-fallback.h> |
| 83 | #ifndef atomic_add_return_relaxed | ||
| 84 | #define atomic_add_return_relaxed atomic_add_return | ||
| 85 | #define atomic_add_return_acquire atomic_add_return | ||
| 86 | #define atomic_add_return_release atomic_add_return | ||
| 87 | |||
| 88 | #else /* atomic_add_return_relaxed */ | ||
| 89 | |||
| 90 | #ifndef atomic_add_return_acquire | ||
| 91 | #define atomic_add_return_acquire(...) \ | ||
| 92 | __atomic_op_acquire(atomic_add_return, __VA_ARGS__) | ||
| 93 | #endif | ||
| 94 | |||
| 95 | #ifndef atomic_add_return_release | ||
| 96 | #define atomic_add_return_release(...) \ | ||
| 97 | __atomic_op_release(atomic_add_return, __VA_ARGS__) | ||
| 98 | #endif | ||
| 99 | |||
| 100 | #ifndef atomic_add_return | ||
| 101 | #define atomic_add_return(...) \ | ||
| 102 | __atomic_op_fence(atomic_add_return, __VA_ARGS__) | ||
| 103 | #endif | ||
| 104 | #endif /* atomic_add_return_relaxed */ | ||
| 105 | |||
| 106 | #ifndef atomic_inc | ||
| 107 | #define atomic_inc(v) atomic_add(1, (v)) | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* atomic_inc_return_relaxed */ | ||
| 111 | #ifndef atomic_inc_return_relaxed | ||
| 112 | |||
| 113 | #ifndef atomic_inc_return | ||
| 114 | #define atomic_inc_return(v) atomic_add_return(1, (v)) | ||
| 115 | #define atomic_inc_return_relaxed(v) atomic_add_return_relaxed(1, (v)) | ||
| 116 | #define atomic_inc_return_acquire(v) atomic_add_return_acquire(1, (v)) | ||
| 117 | #define atomic_inc_return_release(v) atomic_add_return_release(1, (v)) | ||
| 118 | #else /* atomic_inc_return */ | ||
| 119 | #define atomic_inc_return_relaxed atomic_inc_return | ||
| 120 | #define atomic_inc_return_acquire atomic_inc_return | ||
| 121 | #define atomic_inc_return_release atomic_inc_return | ||
| 122 | #endif /* atomic_inc_return */ | ||
| 123 | |||
| 124 | #else /* atomic_inc_return_relaxed */ | ||
| 125 | |||
| 126 | #ifndef atomic_inc_return_acquire | ||
| 127 | #define atomic_inc_return_acquire(...) \ | ||
| 128 | __atomic_op_acquire(atomic_inc_return, __VA_ARGS__) | ||
| 129 | #endif | ||
| 130 | |||
| 131 | #ifndef atomic_inc_return_release | ||
| 132 | #define atomic_inc_return_release(...) \ | ||
| 133 | __atomic_op_release(atomic_inc_return, __VA_ARGS__) | ||
| 134 | #endif | ||
| 135 | |||
| 136 | #ifndef atomic_inc_return | ||
| 137 | #define atomic_inc_return(...) \ | ||
| 138 | __atomic_op_fence(atomic_inc_return, __VA_ARGS__) | ||
| 139 | #endif | ||
| 140 | #endif /* atomic_inc_return_relaxed */ | ||
| 141 | |||
| 142 | /* atomic_sub_return_relaxed */ | ||
| 143 | #ifndef atomic_sub_return_relaxed | ||
| 144 | #define atomic_sub_return_relaxed atomic_sub_return | ||
| 145 | #define atomic_sub_return_acquire atomic_sub_return | ||
| 146 | #define atomic_sub_return_release atomic_sub_return | ||
| 147 | |||
| 148 | #else /* atomic_sub_return_relaxed */ | ||
| 149 | |||
| 150 | #ifndef atomic_sub_return_acquire | ||
| 151 | #define atomic_sub_return_acquire(...) \ | ||
| 152 | __atomic_op_acquire(atomic_sub_return, __VA_ARGS__) | ||
| 153 | #endif | ||
| 154 | |||
| 155 | #ifndef atomic_sub_return_release | ||
| 156 | #define atomic_sub_return_release(...) \ | ||
| 157 | __atomic_op_release(atomic_sub_return, __VA_ARGS__) | ||
| 158 | #endif | ||
| 159 | |||
| 160 | #ifndef atomic_sub_return | ||
| 161 | #define atomic_sub_return(...) \ | ||
| 162 | __atomic_op_fence(atomic_sub_return, __VA_ARGS__) | ||
| 163 | #endif | ||
| 164 | #endif /* atomic_sub_return_relaxed */ | ||
| 165 | |||
| 166 | #ifndef atomic_dec | ||
| 167 | #define atomic_dec(v) atomic_sub(1, (v)) | ||
| 168 | #endif | ||
| 169 | |||
| 170 | /* atomic_dec_return_relaxed */ | ||
| 171 | #ifndef atomic_dec_return_relaxed | ||
| 172 | |||
| 173 | #ifndef atomic_dec_return | ||
| 174 | #define atomic_dec_return(v) atomic_sub_return(1, (v)) | ||
| 175 | #define atomic_dec_return_relaxed(v) atomic_sub_return_relaxed(1, (v)) | ||
| 176 | #define atomic_dec_return_acquire(v) atomic_sub_return_acquire(1, (v)) | ||
| 177 | #define atomic_dec_return_release(v) atomic_sub_return_release(1, (v)) | ||
| 178 | #else /* atomic_dec_return */ | ||
| 179 | #define atomic_dec_return_relaxed atomic_dec_return | ||
| 180 | #define atomic_dec_return_acquire atomic_dec_return | ||
| 181 | #define atomic_dec_return_release atomic_dec_return | ||
| 182 | #endif /* atomic_dec_return */ | ||
| 183 | |||
| 184 | #else /* atomic_dec_return_relaxed */ | ||
| 185 | |||
| 186 | #ifndef atomic_dec_return_acquire | ||
| 187 | #define atomic_dec_return_acquire(...) \ | ||
| 188 | __atomic_op_acquire(atomic_dec_return, __VA_ARGS__) | ||
| 189 | #endif | ||
| 190 | |||
| 191 | #ifndef atomic_dec_return_release | ||
| 192 | #define atomic_dec_return_release(...) \ | ||
| 193 | __atomic_op_release(atomic_dec_return, __VA_ARGS__) | ||
| 194 | #endif | ||
| 195 | |||
| 196 | #ifndef atomic_dec_return | ||
| 197 | #define atomic_dec_return(...) \ | ||
| 198 | __atomic_op_fence(atomic_dec_return, __VA_ARGS__) | ||
| 199 | #endif | ||
| 200 | #endif /* atomic_dec_return_relaxed */ | ||
| 201 | |||
| 202 | |||
| 203 | /* atomic_fetch_add_relaxed */ | ||
| 204 | #ifndef atomic_fetch_add_relaxed | ||
| 205 | #define atomic_fetch_add_relaxed atomic_fetch_add | ||
| 206 | #define atomic_fetch_add_acquire atomic_fetch_add | ||
| 207 | #define atomic_fetch_add_release atomic_fetch_add | ||
| 208 | |||
| 209 | #else /* atomic_fetch_add_relaxed */ | ||
| 210 | |||
| 211 | #ifndef atomic_fetch_add_acquire | ||
| 212 | #define atomic_fetch_add_acquire(...) \ | ||
| 213 | __atomic_op_acquire(atomic_fetch_add, __VA_ARGS__) | ||
| 214 | #endif | ||
| 215 | |||
| 216 | #ifndef atomic_fetch_add_release | ||
| 217 | #define atomic_fetch_add_release(...) \ | ||
| 218 | __atomic_op_release(atomic_fetch_add, __VA_ARGS__) | ||
| 219 | #endif | ||
| 220 | |||
| 221 | #ifndef atomic_fetch_add | ||
| 222 | #define atomic_fetch_add(...) \ | ||
| 223 | __atomic_op_fence(atomic_fetch_add, __VA_ARGS__) | ||
| 224 | #endif | ||
| 225 | #endif /* atomic_fetch_add_relaxed */ | ||
| 226 | |||
| 227 | /* atomic_fetch_inc_relaxed */ | ||
| 228 | #ifndef atomic_fetch_inc_relaxed | ||
| 229 | |||
| 230 | #ifndef atomic_fetch_inc | ||
| 231 | #define atomic_fetch_inc(v) atomic_fetch_add(1, (v)) | ||
| 232 | #define atomic_fetch_inc_relaxed(v) atomic_fetch_add_relaxed(1, (v)) | ||
| 233 | #define atomic_fetch_inc_acquire(v) atomic_fetch_add_acquire(1, (v)) | ||
| 234 | #define atomic_fetch_inc_release(v) atomic_fetch_add_release(1, (v)) | ||
| 235 | #else /* atomic_fetch_inc */ | ||
| 236 | #define atomic_fetch_inc_relaxed atomic_fetch_inc | ||
| 237 | #define atomic_fetch_inc_acquire atomic_fetch_inc | ||
| 238 | #define atomic_fetch_inc_release atomic_fetch_inc | ||
| 239 | #endif /* atomic_fetch_inc */ | ||
| 240 | |||
| 241 | #else /* atomic_fetch_inc_relaxed */ | ||
| 242 | |||
| 243 | #ifndef atomic_fetch_inc_acquire | ||
| 244 | #define atomic_fetch_inc_acquire(...) \ | ||
| 245 | __atomic_op_acquire(atomic_fetch_inc, __VA_ARGS__) | ||
| 246 | #endif | ||
| 247 | |||
| 248 | #ifndef atomic_fetch_inc_release | ||
| 249 | #define atomic_fetch_inc_release(...) \ | ||
| 250 | __atomic_op_release(atomic_fetch_inc, __VA_ARGS__) | ||
| 251 | #endif | ||
| 252 | |||
| 253 | #ifndef atomic_fetch_inc | ||
| 254 | #define atomic_fetch_inc(...) \ | ||
| 255 | __atomic_op_fence(atomic_fetch_inc, __VA_ARGS__) | ||
| 256 | #endif | ||
| 257 | #endif /* atomic_fetch_inc_relaxed */ | ||
| 258 | |||
