diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2018-03-15 06:46:30 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-03-20 03:23:24 -0400 |
| commit | 9b8cce52c4b5c08297900bfdcafc6b08d9bc4a27 (patch) | |
| tree | d6ab6abb1f72998fd12620d54ad8431b83450d42 | |
| parent | 6887a56b6e8ef5daf1160f2ebe5cbe38fd8819a2 (diff) | |
sched/wait: Remove the wait_on_atomic_t() API
There are no users left (everyone got converted to wait_var_event()), remove it.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | include/linux/wait_bit.h | 27 | ||||
| -rw-r--r-- | kernel/sched/wait_bit.c | 101 |
2 files changed, 0 insertions, 128 deletions
diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h index 3fcdb75d69cf..9318b2166439 100644 --- a/include/linux/wait_bit.h +++ b/include/linux/wait_bit.h | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | struct wait_bit_key { | 10 | struct wait_bit_key { |
| 11 | void *flags; | 11 | void *flags; |
| 12 | int bit_nr; | 12 | int bit_nr; |
| 13 | #define WAIT_ATOMIC_T_BIT_NR -1 | ||
| 14 | unsigned long timeout; | 13 | unsigned long timeout; |
| 15 | }; | 14 | }; |
| 16 | 15 | ||
| @@ -22,21 +21,15 @@ struct wait_bit_queue_entry { | |||
| 22 | #define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ | 21 | #define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ |
| 23 | { .flags = word, .bit_nr = bit, } | 22 | { .flags = word, .bit_nr = bit, } |
| 24 | 23 | ||
| 25 | #define __WAIT_ATOMIC_T_KEY_INITIALIZER(p) \ | ||
| 26 | { .flags = p, .bit_nr = WAIT_ATOMIC_T_BIT_NR, } | ||
| 27 | |||
| 28 | typedef int wait_bit_action_f(struct wait_bit_key *key, int mode); | 24 | typedef int wait_bit_action_f(struct wait_bit_key *key, int mode); |
| 29 | typedef int wait_atomic_t_action_f(atomic_t *counter, unsigned int mode); | ||
| 30 | 25 | ||
| 31 | void __wake_up_bit(struct wait_queue_head *wq_head, void *word, int bit); | 26 | void __wake_up_bit(struct wait_queue_head *wq_head, void *word, int bit); |
| 32 | int __wait_on_bit(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, wait_bit_action_f *action, unsigned int mode); | 27 | int __wait_on_bit(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, wait_bit_action_f *action, unsigned int mode); |
| 33 | int __wait_on_bit_lock(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, wait_bit_action_f *action, unsigned int mode); | 28 | int __wait_on_bit_lock(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, wait_bit_action_f *action, unsigned int mode); |
| 34 | void wake_up_bit(void *word, int bit); | 29 | void wake_up_bit(void *word, int bit); |
| 35 | void wake_up_atomic_t(atomic_t *p); | ||
| 36 | int out_of_line_wait_on_bit(void *word, int, wait_bit_action_f *action, unsigned int mode); | 30 | int out_of_line_wait_on_bit(void *word, int, wait_bit_action_f *action, unsigned int mode); |
| 37 | int out_of_line_wait_on_bit_timeout(void *word, int, wait_bit_action_f *action, unsigned int mode, unsigned long timeout); | 31 | int out_of_line_wait_on_bit_timeout(void *word, int, wait_bit_action_f *action, unsigned int mode, unsigned long timeout); |
| 38 | int out_of_line_wait_on_bit_lock(void *word, int, wait_bit_action_f *action, unsigned int mode); | 32 | int out_of_line_wait_on_bit_lock(void *word, int, wait_bit_action_f *action, unsigned int mode); |
| 39 | int out_of_line_wait_on_atomic_t(atomic_t *p, wait_atomic_t_action_f action, unsigned int mode); | ||
| 40 | struct wait_queue_head *bit_waitqueue(void *word, int bit); | 33 | struct wait_queue_head *bit_waitqueue(void *word, int bit); |
| 41 | extern void __init wait_bit_init(void); | 34 | extern void __init wait_bit_init(void); |
| 42 | 35 | ||
| @@ -57,7 +50,6 @@ extern int bit_wait(struct wait_bit_key *key, int mode); | |||
| 57 | extern int bit_wait_io(struct wait_bit_key *key, int mode); | 50 | extern int bit_wait_io(struct wait_bit_key *key, int mode); |
| 58 | extern int bit_wait_timeout(struct wait_bit_key *key, int mode); | 51 | extern int bit_wait_timeout(struct wait_bit_key *key, int mode); |
| 59 | extern int bit_wait_io_timeout(struct wait_bit_key *key, int mode); | 52 | extern int bit_wait_io_timeout(struct wait_bit_key *key, int mode); |
| 60 | extern int atomic_t_wait(atomic_t *counter, unsigned int mode); | ||
| 61 | 53 | ||
| 62 | /** | 54 | /** |
| 63 | * wait_on_bit - wait for a bit to be cleared | 55 | * wait_on_bit - wait for a bit to be cleared |
| @@ -243,25 +235,6 @@ wait_on_bit_lock_action(unsigned long *word, int bit, wait_bit_action_f *action, | |||
| 243 | return out_of_line_wait_on_bit_lock(word, bit, action, mode); | 235 | return out_of_line_wait_on_bit_lock(word, bit, action, mode); |
| 244 | } | 236 | } |
| 245 | 237 | ||
| 246 | /** | ||
| 247 | * wait_on_atomic_t - Wait for an atomic_t to become 0 | ||
| 248 | * @val: The atomic value being waited on, a kernel virtual address | ||
| 249 | * @action: the function used to sleep, which may take special actions | ||
| 250 | * @mode: the task state to sleep in | ||
| 251 | * | ||
| 252 | * Wait for an atomic_t to become 0. We abuse the bit-wait waitqueue table for | ||
| 253 | * the purpose of getting a waitqueue, but we set the key to a bit number | ||
| 254 | * outside of the target 'word'. | ||
| 255 | */ | ||
| 256 | static inline | ||
| 257 | int wait_on_atomic_t(atomic_t *val, wait_atomic_t_action_f action, unsigned mode) | ||
| 258 | { | ||
| 259 | might_sleep(); | ||
| 260 | if (atomic_read(val) == 0) | ||
| 261 | return 0; | ||
| 262 | return out_of_line_wait_on_atomic_t(val, action, mode); | ||
| 263 | } | ||
| 264 | |||
| 265 | extern void init_wait_var_entry(struct wait_bit_queue_entry *wbq_entry, void *var, int flags); | 238 | extern void init_wait_var_entry(struct wait_bit_queue_entry *wbq_entry, void *var, int flags); |
| 266 | extern void wake_up_var(void *var); | 239 | extern void wake_up_var(void *var); |
| 267 | extern wait_queue_head_t *__var_waitqueue(void *p); | 240 | extern wait_queue_head_t *__var_waitqueue(void *p); |
diff --git a/kernel/sched/wait_bit.c b/kernel/sched/wait_bit.c index ed84ab245a05..60a84f5a6cb4 100644 --- a/kernel/sched/wait_bit.c +++ b/kernel/sched/wait_bit.c | |||
| @@ -197,107 +197,6 @@ void wake_up_var(void *var) | |||
| 197 | } | 197 | } |
| 198 | EXPORT_SYMBOL(wake_up_var); | 198 | EXPORT_SYMBOL(wake_up_var); |
| 199 | 199 | ||
| 200 | /* | ||
| 201 | * Manipulate the atomic_t address to produce a better bit waitqueue table hash | ||
| 202 | * index (we're keying off bit -1, but that would produce a horrible hash | ||
| 203 | * value). | ||
| 204 | */ | ||
| 205 | static inline wait_queue_head_t *atomic_t_waitqueue(atomic_t *p) | ||
| 206 | { | ||
| 207 | if (BITS_PER_LONG == 64) { | ||
| 208 | unsigned long q = (unsigned long)p; | ||
| 209 | |||
| 210 | return bit_waitqueue((void *)(q & ~1), q & 1); | ||
| 211 | } | ||
| 212 | return bit_waitqueue(p, 0); | ||
| 213 | } | ||
| 214 | |||
| 215 | static int wake_atomic_t_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, | ||
| 216 | void *arg) | ||
| 217 | { | ||
| 218 | struct wait_bit_key *key = arg; | ||
| 219 | struct wait_bit_queue_entry *wait_bit = container_of(wq_entry, struct wait_bit_queue_entry, wq_entry); | ||
| 220 | atomic_t *val = key->flags; | ||
| 221 | |||
| 222 | if (wait_bit->key.flags != key->flags || | ||
| 223 | wait_bit->key.bit_nr != key->bit_nr || | ||
| 224 | atomic_read(val) != 0) | ||
| 225 | return 0; | ||
| 226 | |||
| 227 | return autoremove_wake_function(wq_entry, mode, sync, key); | ||
| 228 | } | ||
| 229 | |||
| 230 | /* | ||
| 231 | * To allow interruptible waiting and asynchronous (i.e. nonblocking) waiting, | ||
| 232 | * the actions of __wait_on_atomic_t() are permitted return codes. Nonzero | ||
| 233 | * return codes halt waiting and return. | ||
| 234 | */ | ||
| 235 | static __sched | ||
| 236 | int __wait_on_atomic_t(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, | ||
| 237 | wait_atomic_t_action_f action, unsigned int mode) | ||
| 238 | { | ||
| 239 | atomic_t *val; | ||
| 240 | int ret = 0; | ||
| 241 | |||
| 242 | do { | ||
| 243 | prepare_to_wait(wq_head, &wbq_entry->wq_entry, mode); | ||
| 244 | val = wbq_entry->key.flags; | ||
| 245 | if (atomic_read(val) == 0) | ||
| 246 | break; | ||
| 247 | ret = (*action)(val, mode); | ||
| 248 | } while (!ret && atomic_read(val) != 0); | ||
| 249 | finish_wait(wq_head, &wbq_entry->wq_entry); | ||
| 250 | |||
| 251 | return ret; | ||
| 252 | } | ||
| 253 | |||
| 254 | #define DEFINE_WAIT_ATOMIC_T(name, p) \ | ||
| 255 | struct wait_bit_queue_entry name = { \ | ||
| 256 | .key = __WAIT_ATOMIC_T_KEY_INITIALIZER(p), \ | ||
| 257 | .wq_entry = { \ | ||
| 258 | .private = current, \ | ||
| 259 | .func = wake_atomic_t_function, \ | ||
| 260 | .entry = \ | ||
| 261 | LIST_HEAD_INIT((name).wq_entry.entry), \ | ||
| 262 | }, \ | ||
| 263 | } | ||
| 264 | |||
| 265 | __sched int out_of_line_wait_on_atomic_t(atomic_t *p, | ||
| 266 | wait_atomic_t_action_f action, | ||
| 267 | unsigned int mode) | ||
| 268 | { | ||
| 269 | struct wait_queue_head *wq_head = atomic_t_waitqueue(p); | ||
| 270 | DEFINE_WAIT_ATOMIC_T(wq_entry, p); | ||
| 271 | |||
| 272 | return __wait_on_atomic_t(wq_head, &wq_entry, action, mode); | ||
| 273 | } | ||
| 274 | EXPORT_SYMBOL(out_of_line_wait_on_atomic_t); | ||
| 275 | |||
| 276 | __sched int atomic_t_wait(atomic_t *counter, unsigned int mode) | ||
| 277 | { | ||
| 278 | schedule(); | ||
| 279 | if (signal_pending_state(mode, current)) | ||
| 280 | return -EINTR; | ||
| 281 | |||
| 282 | return 0; | ||
| 283 | } | ||
| 284 | EXPORT_SYMBOL(atomic_t_wait); | ||
| 285 | |||
| 286 | /** | ||
| 287 | * wake_up_atomic_t - Wake up a waiter on a atomic_t | ||
| 288 | * @p: The atomic_t being waited on, a kernel virtual address | ||
| 289 | * | ||
| 290 | * Wake up anyone waiting for the atomic_t to go to zero. | ||
| 291 | * | ||
| 292 | * Abuse the bit-waker function and its waitqueue hash table set (the atomic_t | ||
| 293 | * check is done by the waiter's wake function, not the by the waker itself). | ||
| 294 | */ | ||
| 295 | void wake_up_atomic_t(atomic_t *p) | ||
| 296 | { | ||
| 297 | __wake_up_bit(atomic_t_waitqueue(p), p, WAIT_ATOMIC_T_BIT_NR); | ||
| 298 | } | ||
| 299 | EXPORT_SYMBOL(wake_up_atomic_t); | ||
| 300 | |||
| 301 | __sched int bit_wait(struct wait_bit_key *word, int mode) | 200 | __sched int bit_wait(struct wait_bit_key *word, int mode) |
| 302 | { | 201 | { |
| 303 | schedule(); | 202 | schedule(); |
