···1363{1364 struct futex_hash_bucket *hb;13651366- get_futex_key_refs(&q->key);1367 hb = hash_futex(&q->key);1368 q->lock_ptr = &hb->lock;1369···1374queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb)1375{1376 spin_unlock(&hb->lock);1377- drop_futex_key_refs(&q->key);1378}13791380/**···1478 q->pi_state = NULL;14791480 spin_unlock(q->lock_ptr);1481-1482- drop_futex_key_refs(&q->key);1483}14841485/*···1808 }18091810retry:1811- /* Prepare to wait on uaddr. */0001812 ret = futex_wait_setup(uaddr, val, fshared, &q, &hb);1813 if (ret)1814 goto out;···18211822 /* If we were woken (and unqueued), we succeeded, whatever. */1823 ret = 0;01824 if (!unqueue_me(&q))1825- goto out_put_key;1826 ret = -ETIMEDOUT;1827 if (to && !to->task)1828- goto out_put_key;18291830 /*1831 * We expect signal_pending(current), but we might be the1832 * victim of a spurious wakeup as well.1833 */1834- if (!signal_pending(current)) {1835- put_futex_key(fshared, &q.key);1836 goto retry;1837- }18381839 ret = -ERESTARTSYS;1840 if (!abs_time)1841- goto out_put_key;18421843 restart = ¤t_thread_info()->restart_block;1844 restart->fn = futex_wait_restart;···18541855 ret = -ERESTART_RESTARTBLOCK;18561857-out_put_key:1858- put_futex_key(fshared, &q.key);1859out:1860 if (to) {1861 hrtimer_cancel(&to->timer);···2232 q.rt_waiter = &rt_waiter;2233 q.requeue_pi_key = &key2;22342235- /* Prepare to wait on uaddr. */0002236 ret = futex_wait_setup(uaddr, val, fshared, &q, &hb);2237 if (ret)2238 goto out_key2;···2253 * In order for us to be here, we know our q.key == key2, and since2254 * we took the hb->lock above, we also know that futex_requeue() has2255 * completed and we no longer have to concern ourselves with a wakeup2256- * race with the atomic proxy lock acquition by the requeue code.002257 */22582259 /* Check if the requeue code acquired the second futex for us. */
···1363{1364 struct futex_hash_bucket *hb;136501366 hb = hash_futex(&q->key);1367 q->lock_ptr = &hb->lock;1368···1375queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb)1376{1377 spin_unlock(&hb->lock);01378}13791380/**···1480 q->pi_state = NULL;14811482 spin_unlock(q->lock_ptr);001483}14841485/*···1812 }18131814retry:1815+ /*1816+ * Prepare to wait on uaddr. On success, holds hb lock and increments1817+ * q.key refs.1818+ */1819 ret = futex_wait_setup(uaddr, val, fshared, &q, &hb);1820 if (ret)1821 goto out;···18221823 /* If we were woken (and unqueued), we succeeded, whatever. */1824 ret = 0;1825+ /* unqueue_me() drops q.key ref */1826 if (!unqueue_me(&q))1827+ goto out;1828 ret = -ETIMEDOUT;1829 if (to && !to->task)1830+ goto out;18311832 /*1833 * We expect signal_pending(current), but we might be the1834 * victim of a spurious wakeup as well.1835 */1836+ if (!signal_pending(current))01837 goto retry;018381839 ret = -ERESTARTSYS;1840 if (!abs_time)1841+ goto out;18421843 restart = ¤t_thread_info()->restart_block;1844 restart->fn = futex_wait_restart;···18561857 ret = -ERESTART_RESTARTBLOCK;1858001859out:1860 if (to) {1861 hrtimer_cancel(&to->timer);···2236 q.rt_waiter = &rt_waiter;2237 q.requeue_pi_key = &key2;22382239+ /*2240+ * Prepare to wait on uaddr. On success, increments q.key (key1) ref2241+ * count.2242+ */2243 ret = futex_wait_setup(uaddr, val, fshared, &q, &hb);2244 if (ret)2245 goto out_key2;···2254 * In order for us to be here, we know our q.key == key2, and since2255 * we took the hb->lock above, we also know that futex_requeue() has2256 * completed and we no longer have to concern ourselves with a wakeup2257+ * race with the atomic proxy lock acquisition by the requeue code. The2258+ * futex_requeue dropped our key1 reference and incremented our key22259+ * reference count.2260 */22612262 /* Check if the requeue code acquired the second futex for us. */