diff options
| -rw-r--r-- | kernel/futex.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index 6c498b145a4f..cedcd60f26ff 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -1350,6 +1350,25 @@ static inline struct futex_hash_bucket *queue_lock(struct futex_q *q) | |||
| 1350 | return hb; | 1350 | return hb; |
| 1351 | } | 1351 | } |
| 1352 | 1352 | ||
| 1353 | static inline void | ||
| 1354 | queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb) | ||
| 1355 | { | ||
| 1356 | spin_unlock(&hb->lock); | ||
| 1357 | drop_futex_key_refs(&q->key); | ||
| 1358 | } | ||
| 1359 | |||
| 1360 | /** | ||
| 1361 | * queue_me() - Enqueue the futex_q on the futex_hash_bucket | ||
| 1362 | * @q: The futex_q to enqueue | ||
| 1363 | * @hb: The destination hash bucket | ||
| 1364 | * | ||
| 1365 | * The hb->lock must be held by the caller, and is released here. A call to | ||
| 1366 | * queue_me() is typically paired with exactly one call to unqueue_me(). The | ||
| 1367 | * exceptions involve the PI related operations, which may use unqueue_me_pi() | ||
| 1368 | * or nothing if the unqueue is done as part of the wake process and the unqueue | ||
| 1369 | * state is implicit in the state of woken task (see futex_wait_requeue_pi() for | ||
| 1370 | * an example). | ||
| 1371 | */ | ||
| 1353 | static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb) | 1372 | static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb) |
| 1354 | { | 1373 | { |
| 1355 | int prio; | 1374 | int prio; |
| @@ -1373,19 +1392,17 @@ static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb) | |||
| 1373 | spin_unlock(&hb->lock); | 1392 | spin_unlock(&hb->lock); |
| 1374 | } | 1393 | } |
| 1375 | 1394 | ||
| 1376 | static inline void | 1395 | /** |
| 1377 | queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb) | 1396 | * unqueue_me() - Remove the futex_q from its futex_hash_bucket |
| 1378 | { | 1397 | * @q: The futex_q to unqueue |
| 1379 | spin_unlock(&hb->lock); | 1398 | * |
| 1380 | drop_futex_key_refs(&q->key); | 1399 | * The q->lock_ptr must not be held by the caller. A call to unqueue_me() must |
| 1381 | } | 1400 | * be paired with exactly one earlier call to queue_me(). |
| 1382 | 1401 | * | |
| 1383 | /* | 1402 | * Returns: |
| 1384 | * queue_me and unqueue_me must be called as a pair, each | 1403 | * 1 - if the futex_q was still queued (and we removed unqueued it) |
| 1385 | * exactly once. They are called with the hashed spinlock held. | 1404 | * 0 - if the futex_q was already removed by the waking thread |
| 1386 | */ | 1405 | */ |
| 1387 | |||
| 1388 | /* Return 1 if we were still queued (ie. 0 means we were woken) */ | ||
| 1389 | static int unqueue_me(struct futex_q *q) | 1406 | static int unqueue_me(struct futex_q *q) |
| 1390 | { | 1407 | { |
| 1391 | spinlock_t *lock_ptr; | 1408 | spinlock_t *lock_ptr; |
