From 6f29c630d98d0dbd585e04a81d53c3aa6e73f31b Mon Sep 17 00:00:00 2001 From: mjg Date: Sat, 13 Jan 2018 00:05:31 +0000 Subject: [PATCH] rwlock: try regular read unlock even in the hard path Saves on turnstile trips if the lock got more readers. --- sys/kern/kern_rwlock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 025ced411fd0..7459cde5e283 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -771,9 +771,9 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v turnstile_chain_lock(&rw->lock_object); v = RW_READ_VALUE(rw); retry_ts: - if (__predict_false(RW_READERS(v) > 1)) { + if (__rw_runlock_try(rw, td, &v)) { turnstile_chain_unlock(&rw->lock_object); - continue; + break; } v &= (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER);