git: 83d13d836b32 - main - locks: run the extra NULL check only with INVARIANTS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 30 Mar 2025 04:01:29 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=83d13d836b32af86bba62ddf86c2ef78389d13fd commit 83d13d836b32af86bba62ddf86c2ef78389d13fd Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2025-03-30 03:55:31 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2025-03-30 03:56:05 +0000 locks: run the extra NULL check only with INVARIANTS This reverts commit 73da0265c29c79641dab3e6b98452bd5afca01fb. This reverts commit 87ee63bac69dc49291f55590b8baa57cad6c7d85. Discussed with: mjg --- sys/kern/kern_mutex.c | 4 +--- sys/kern/kern_rwlock.c | 16 ++++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index d52f7e1eebd1..f952b3fc8805 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -1073,9 +1073,7 @@ __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v) turnstile_chain_lock(&m->lock_object); _mtx_release_lock_quick(m); ts = turnstile_lookup(&m->lock_object); - if (__predict_false(ts == NULL)) { - panic("got NULL turnstile on mutex %p v %p", m, (void *)v); - } + MPASS(ts != NULL); if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m); turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE); diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index ed6ca75bc7a5..e182d1fe9baf 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -784,12 +784,11 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v LOCK_FILE_LINE_ARG_DEF) { struct turnstile *ts; - uintptr_t setv, passedv, queue; + uintptr_t setv, queue; if (SCHEDULER_STOPPED()) return; - passedv = v; if (__rw_runlock_try(rw, td, &v)) goto out_lockstat; @@ -842,10 +841,7 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v * release the lock. */ ts = turnstile_lookup(&rw->lock_object); - if (__predict_false(ts == NULL)) { - panic("got NULL turnstile on rwlock %p passedv %p v %p", - rw, (void *)passedv, (void *)v); - } + MPASS(ts != NULL); turnstile_broadcast(ts, queue); turnstile_unpend(ts); td->td_rw_rlocks--; @@ -1223,7 +1219,7 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF) { struct rwlock *rw; struct turnstile *ts; - uintptr_t tid, setv, passedv; + uintptr_t tid, setv; int queue; tid = (uintptr_t)curthread; @@ -1271,7 +1267,6 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF) * of waiters or doing some complicated lock handoff gymnastics. */ setv = RW_UNLOCKED; - passedv = v; v = RW_READ_VALUE(rw); queue = TS_SHARED_QUEUE; if (v & RW_LOCK_WRITE_WAITERS) { @@ -1286,10 +1281,7 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF) queue == TS_SHARED_QUEUE ? "read" : "write"); ts = turnstile_lookup(&rw->lock_object); - if (__predict_false(ts == NULL)) { - panic("got NULL turnstile on rwlock %p passedv %p v %p", rw, - (void *)passedv, (void *)v); - } + MPASS(ts != NULL); turnstile_broadcast(ts, queue); turnstile_unpend(ts); turnstile_chain_unlock(&rw->lock_object);