Lines Matching +full:timer +full:- +full:cannot +full:- +full:wake +full:- +full:cpu
1 // SPDX-License-Identifier: GPL-2.0-or-later
28 * In futex wake up scenarios where no tasks are blocked on a futex, taking
34 * CPU 0 CPU 1
40 * sys_futex(WAKE, futex);
50 * This would cause the waiter on CPU 0 to wait forever because it
58 * CPU 0 CPU 1
64 * smp_mb(); (A) <-- paired with -.
70 * | sys_futex(WAKE, futex);
73 * `--------> smp_mb(); (B)
80 * waiters--; (b) unlock(hash_bucket(futex));
95 * the guarantee that we cannot both miss the futex variable change and the
104 * acquiring the lock. It then decrements them again after releasing it -
112 if (WARN(q->pi_state || q->rt_waiter, "refusing to wake PI futex\n"))
117 * The waiting task can free the futex_q as soon as q->lock_ptr = NULL
123 smp_store_release(&q->lock_ptr, NULL);
136 struct task_struct *p = q->task;
147 * the hb->lock.
153 * Wake up waiters matching bitset queued on this futex (uaddr).
163 return -EINVAL;
178 spin_lock(&hb->lock);
180 plist_for_each_entry_safe(this, next, &hb->chain, list) {
181 if (futex_match (&this->key, &key)) {
182 if (this->pi_state || this->rt_waiter) {
183 ret = -EINVAL;
188 if (!(this->bitset & bitset))
191 this->wake(&wake_q, this);
197 spin_unlock(&hb->lock);
213 * kill this print and return -EINVAL when userspace
217 current->comm, oparg);
243 return -ENOSYS;
248 * Wake up all waiters hashed on the physical page that is mapped
278 unlikely(op_ret != -EFAULT && op_ret != -EAGAIN)) {
287 if (op_ret == -EFAULT) {
299 plist_for_each_entry_safe(this, next, &hb1->chain, list) {
300 if (futex_match(&this->key, &key1)) {
301 if (this->pi_state || this->rt_waiter) {
302 ret = -EINVAL;
305 this->wake(&wake_q, this);
313 plist_for_each_entry_safe(this, next, &hb2->chain, list) {
314 if (futex_match(&this->key, &key2)) {
315 if (this->pi_state || this->rt_waiter) {
316 ret = -EINVAL;
319 this->wake(&wake_q, this);
337 * futex_do_wait() - wait for wakeup, timeout, or signal
343 /* Arm the timer */
349 * has tried to wake us, and we can skip the call to schedule().
351 if (likely(!plist_node_empty(&q->list))) {
353 * If the timer has already expired, current will already be
357 if (!timeout || timeout->task)
364 * futex_unqueue_multiple - Remove various futexes from their hash bucket
371 * - >=0 - Index of the last futex that was awoken;
372 * - -1 - No futex was awoken
376 int ret = -1, i;
387 * futex_wait_multiple_setup - Prepare to wait and enqueue multiple futexes
398 * - 1 - One of the futexes was woken by another thread
399 * - 0 - Success
400 * - <0 - -EFAULT, -EWOULDBLOCK or -EINVAL
418 * make sure that current->state is TASK_INTERRUPTIBLE, so we don't
419 * lose any wake events, which cannot be done before the get_futex_key
449 CLASS(hb, hb)(&q->key);
486 return -EFAULT;
493 return -EWOULDBLOCK;
500 * futex_sleep_multiple - Check sleeping conditions and sleep
511 if (to && !to->task)
514 for (; count; count--, vs++) {
515 if (!READ_ONCE(vs->q.lock_ptr))
523 * futex_wait_multiple - Prepare to wait on and enqueue several futexes
530 * wake, or after the timeout has elapsed.
533 * - >=0 - Hint to the futex that was awoken
534 * - <0 - On error
562 if (to && !to->task)
563 return -ETIMEDOUT;
565 return -ERESTARTSYS;
574 * futex_wait_setup() - Prepare to wait on a futex
587 * - 0 - uaddr contains val and hb has been locked;
588 * - <0 - On error and the hb is unlocked. A possible reason: the uaddr can not
599 * Access the page AFTER the hash-bucket is locked.
607 * any cond. If we locked the hash-bucket after testing *uaddr, that
611 * On the other hand, we insert q and release the hash-bucket only
617 ret = get_futex_key(uaddr, flags, &q->key, FUTEX_READ);
623 CLASS(hb, hb)(&q->key);
644 return -EWOULDBLOCK;
647 if (key2 && futex_match(&q->key, key2)) {
649 return -EINVAL;
654 * wake it. set_current_state() is implemented using smp_store_mb() and
673 return -EINVAL;
679 * Prepare to wait on uaddr. On success, it holds hb->lock and q
693 if (to && !to->task)
694 return -ETIMEDOUT;
703 return -ERESTARTSYS;
713 current->timer_slack_ns);
721 hrtimer_cancel(&to->timer);
722 destroy_hrtimer_on_stack(&to->timer);
724 if (ret == -ERESTARTSYS) {
725 restart = ¤t->restart_block;
726 restart->futex.uaddr = uaddr;
727 restart->futex.val = val;
728 restart->futex.time = *abs_time;
729 restart->futex.bitset = bitset;
730 restart->futex.flags = flags | FLAGS_HAS_TIMEOUT;
740 u32 __user *uaddr = restart->futex.uaddr;
743 if (restart->futex.flags & FLAGS_HAS_TIMEOUT) {
744 t = restart->futex.time;
747 restart->fn = do_no_restart_syscall;
749 return (long)futex_wait(uaddr, restart->futex.flags,
750 restart->futex.val, tp, restart->futex.bitset);