diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2025-04-16 18:29:06 +0200 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2025-05-03 12:02:06 +0200 |
| commit | 6c67f8d880c0950215b8e6f8539562ad1971a05a (patch) | |
| tree | 0ecfbe1e5ae3666c84d6fd684d149fc4837d200e /kernel/futex/pi.c | |
| parent | 8486d12f558ff9e4e90331e8ef841d84bf3a8c24 (diff) | |
| download | linux-next-6c67f8d880c0950215b8e6f8539562ad1971a05a.tar.gz linux-next-6c67f8d880c0950215b8e6f8539562ad1971a05a.zip | |
futex: Create futex_hash() get/put class
This gets us:
hb = futex_hash(key) /* gets hb and inc users */
futex_hash_get(hb) /* inc users */
futex_hash_put(hb) /* dec users */
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-7-bigeasy@linutronix.de
Diffstat (limited to 'kernel/futex/pi.c')
| -rw-r--r-- | kernel/futex/pi.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/futex/pi.c b/kernel/futex/pi.c index a56f28fda58d..e52f540e81b6 100644 --- a/kernel/futex/pi.c +++ b/kernel/futex/pi.c @@ -939,9 +939,8 @@ retry: retry_private: if (1) { - struct futex_hash_bucket *hb; + CLASS(hb, hb)(&q.key); - hb = futex_hash(&q.key); futex_q_lock(&q, hb); ret = futex_lock_pi_atomic(uaddr, hb, &q.key, &q.pi_state, current, @@ -995,6 +994,16 @@ retry_private: } /* + * Caution; releasing @hb in-scope. The hb->lock is still locked + * while the reference is dropped. The reference can not be dropped + * after the unlock because if a user initiated resize is in progress + * then we might need to wake him. This can not be done after the + * rt_mutex_pre_schedule() invocation. The hb will remain valid because + * the thread, performing resize, will block on hb->lock during + * the requeue. + */ + futex_hash_put(no_free_ptr(hb)); + /* * Must be done before we enqueue the waiter, here is unfortunately * under the hb lock, but that *should* work because it does nothing. */ @@ -1119,7 +1128,6 @@ int futex_unlock_pi(u32 __user *uaddr, unsigned int flags) { u32 curval, uval, vpid = task_pid_vnr(current); union futex_key key = FUTEX_KEY_INIT; - struct futex_hash_bucket *hb; struct futex_q *top_waiter; int ret; @@ -1139,7 +1147,7 @@ retry: if (ret) return ret; - hb = futex_hash(&key); + CLASS(hb, hb)(&key); spin_lock(&hb->lock); retry_hb: |
