From owner-svn-src-head@freebsd.org Wed Feb 14 20:37:34 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE2B9F1E521; Wed, 14 Feb 2018 20:37:34 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 54EB06C0B9; Wed, 14 Feb 2018 20:37:34 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4691214CA1; Wed, 14 Feb 2018 20:37:34 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1EKbYho011261; Wed, 14 Feb 2018 20:37:34 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1EKbYuf011260; Wed, 14 Feb 2018 20:37:34 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201802142037.w1EKbYuf011260@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 14 Feb 2018 20:37:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329276 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 329276 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Feb 2018 20:37:34 -0000 Author: mjg Date: Wed Feb 14 20:37:33 2018 New Revision: 329276 URL: https://svnweb.freebsd.org/changeset/base/329276 Log: rwlock: diff-reduction of runlock compared to sx sunlock Modified: head/sys/kern/kern_rwlock.c Modified: head/sys/kern/kern_rwlock.c ============================================================================== --- head/sys/kern/kern_rwlock.c Wed Feb 14 20:26:09 2018 (r329275) +++ head/sys/kern/kern_rwlock.c Wed Feb 14 20:37:33 2018 (r329276) @@ -760,22 +760,19 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td if (SCHEDULER_STOPPED()) return; + if (__rw_runlock_try(rw, td, &v)) + goto out_lockstat; + + /* + * Ok, we know we have waiters and we think we are the + * last reader, so grab the turnstile lock. + */ + turnstile_chain_lock(&rw->lock_object); + v = RW_READ_VALUE(rw); for (;;) { if (__rw_runlock_try(rw, td, &v)) break; - /* - * Ok, we know we have waiters and we think we are the - * last reader, so grab the turnstile lock. - */ - turnstile_chain_lock(&rw->lock_object); - v = RW_READ_VALUE(rw); -retry_ts: - if (__rw_runlock_try(rw, td, &v)) { - turnstile_chain_unlock(&rw->lock_object); - break; - } - v &= (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER); MPASS(v & RW_LOCK_WAITERS); @@ -803,7 +800,7 @@ retry_ts: } v |= RW_READERS_LOCK(1); if (!atomic_fcmpset_rel_ptr(&rw->rw_lock, &v, setv)) - goto retry_ts; + continue; if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p last succeeded with waiters", __func__, rw); @@ -819,10 +816,11 @@ retry_ts: MPASS(ts != NULL); turnstile_broadcast(ts, queue); turnstile_unpend(ts, TS_SHARED_LOCK); - turnstile_chain_unlock(&rw->lock_object); td->td_rw_rlocks--; break; } + turnstile_chain_unlock(&rw->lock_object); +out_lockstat: LOCKSTAT_PROFILE_RELEASE_RWLOCK(rw__release, rw, LOCKSTAT_READER); }