Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

futex: Pull futex_hash() out of futex_q_lock()

Getting the hash bucket and queuing it are two distinct actions. In
light of wanting to add a put hash bucket function later, untangle
them.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250416162921.513656-5-bigeasy@linutronix.de

+8 -10
+1 -6
kernel/futex/core.c
··· 502 502 } 503 503 504 504 /* The key must be already stored in q->key. */ 505 - struct futex_hash_bucket *futex_q_lock(struct futex_q *q) 505 + void futex_q_lock(struct futex_q *q, struct futex_hash_bucket *hb) 506 506 __acquires(&hb->lock) 507 507 { 508 - struct futex_hash_bucket *hb; 509 - 510 - hb = futex_hash(&q->key); 511 - 512 508 /* 513 509 * Increment the counter before taking the lock so that 514 510 * a potential waker won't miss a to-be-slept task that is ··· 518 522 q->lock_ptr = &hb->lock; 519 523 520 524 spin_lock(&hb->lock); 521 - return hb; 522 525 } 523 526 524 527 void futex_q_unlock(struct futex_hash_bucket *hb)
+1 -1
kernel/futex/futex.h
··· 354 354 #endif 355 355 } 356 356 357 - extern struct futex_hash_bucket *futex_q_lock(struct futex_q *q); 357 + extern void futex_q_lock(struct futex_q *q, struct futex_hash_bucket *hb); 358 358 extern void futex_q_unlock(struct futex_hash_bucket *hb); 359 359 360 360
+2 -1
kernel/futex/pi.c
··· 939 939 goto out; 940 940 941 941 retry_private: 942 - hb = futex_q_lock(&q); 942 + hb = futex_hash(&q.key); 943 + futex_q_lock(&q, hb); 943 944 944 945 ret = futex_lock_pi_atomic(uaddr, hb, &q.key, &q.pi_state, current, 945 946 &exiting, 0);
+4 -2
kernel/futex/waitwake.c
··· 441 441 struct futex_q *q = &vs[i].q; 442 442 u32 val = vs[i].w.val; 443 443 444 - hb = futex_q_lock(q); 444 + hb = futex_hash(&q->key); 445 + futex_q_lock(q, hb); 445 446 ret = futex_get_value_locked(&uval, uaddr); 446 447 447 448 if (!ret && uval == val) { ··· 612 611 return ret; 613 612 614 613 retry_private: 615 - hb = futex_q_lock(q); 614 + hb = futex_hash(&q->key); 615 + futex_q_lock(q, hb); 616 616 617 617 ret = futex_get_value_locked(&uval, uaddr); 618 618