From owner-svn-src-head@freebsd.org Sat May 19 05:09:11 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 79D96EEEEF6; Sat, 19 May 2018 05:09:11 +0000 (UTC) (envelope-from mmacy@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 166107ED2F; Sat, 19 May 2018 05:09:11 +0000 (UTC) (envelope-from mmacy@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 E66A522876; Sat, 19 May 2018 05:09:10 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4J59AuH053546; Sat, 19 May 2018 05:09:10 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4J59Atx053545; Sat, 19 May 2018 05:09:10 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201805190509.w4J59Atx053545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Sat, 19 May 2018 05:09:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333859 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 333859 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.26 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: Sat, 19 May 2018 05:09:11 -0000 Author: mmacy Date: Sat May 19 05:09:10 2018 New Revision: 333859 URL: https://svnweb.freebsd.org/changeset/base/333859 Log: umtx: don't call umtxq_getchain unless the value is needed Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Sat May 19 05:07:31 2018 (r333858) +++ head/sys/kern/kern_umtx.c Sat May 19 05:09:10 2018 (r333859) @@ -662,11 +662,9 @@ umtxq_remove_queue(struct umtx_q *uq, int q) static int umtxq_count(struct umtx_key *key) { - struct umtxq_chain *uc; struct umtxq_queue *uh; - uc = umtxq_getchain(key); - UMTXQ_LOCKED_ASSERT(uc); + UMTXQ_LOCKED_ASSERT(umtxq_getchain(key)); uh = umtxq_queue_lookup(key, UMTX_SHARED_QUEUE); if (uh != NULL) return (uh->length); @@ -680,12 +678,10 @@ umtxq_count(struct umtx_key *key) static int umtxq_count_pi(struct umtx_key *key, struct umtx_q **first) { - struct umtxq_chain *uc; struct umtxq_queue *uh; *first = NULL; - uc = umtxq_getchain(key); - UMTXQ_LOCKED_ASSERT(uc); + UMTXQ_LOCKED_ASSERT(umtxq_getchain(key)); uh = umtxq_queue_lookup(key, UMTX_SHARED_QUEUE); if (uh != NULL) { *first = TAILQ_FIRST(&uh->head); @@ -727,14 +723,12 @@ umtxq_check_susp(struct thread *td) static int umtxq_signal_queue(struct umtx_key *key, int n_wake, int q) { - struct umtxq_chain *uc; struct umtxq_queue *uh; struct umtx_q *uq; int ret; ret = 0; - uc = umtxq_getchain(key); - UMTXQ_LOCKED_ASSERT(uc); + UMTXQ_LOCKED_ASSERT(umtxq_getchain(key)); uh = umtxq_queue_lookup(key, q); if (uh != NULL) { while ((uq = TAILQ_FIRST(&uh->head)) != NULL) { @@ -754,10 +748,8 @@ umtxq_signal_queue(struct umtx_key *key, int n_wake, i static inline void umtxq_signal_thread(struct umtx_q *uq) { - struct umtxq_chain *uc; - uc = umtxq_getchain(&uq->uq_key); - UMTXQ_LOCKED_ASSERT(uc); + UMTXQ_LOCKED_ASSERT(umtxq_getchain(&uq->uq_key)); umtxq_remove(uq); wakeup(uq); } @@ -1663,16 +1655,18 @@ static int umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, uint32_t owner, const char *wmesg, struct abs_timeout *timo, bool shared) { - struct umtxq_chain *uc; struct thread *td, *td1; struct umtx_q *uq1; int error, pri; +#ifdef INVARIANTS + struct umtxq_chain *uc; + uc = umtxq_getchain(&pi->pi_key); +#endif error = 0; td = uq->uq_thread; KASSERT(td == curthread, ("inconsistent uq_thread")); - uc = umtxq_getchain(&uq->uq_key); - UMTXQ_LOCKED_ASSERT(uc); + UMTXQ_LOCKED_ASSERT(umtxq_getchain(&uq->uq_key)); KASSERT(uc->uc_busy != 0, ("umtx chain is not busy")); umtxq_insert(uq); mtx_lock(&umtx_lock); @@ -1728,10 +1722,8 @@ umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, static void umtx_pi_ref(struct umtx_pi *pi) { - struct umtxq_chain *uc; - uc = umtxq_getchain(&pi->pi_key); - UMTXQ_LOCKED_ASSERT(uc); + UMTXQ_LOCKED_ASSERT(umtxq_getchain(&pi->pi_key)); pi->pi_refcount++; }