From owner-svn-src-stable@freebsd.org Thu Mar 16 08:35:29 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E444D0E841; Thu, 16 Mar 2017 08:35:29 +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 mx1.freebsd.org (Postfix) with ESMTPS id 265101694; Thu, 16 Mar 2017 08:35:29 +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 v2G8ZSsj033080; Thu, 16 Mar 2017 08:35:28 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2G8ZSp2033079; Thu, 16 Mar 2017 08:35:28 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201703160835.v2G8ZSp2033079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 16 Mar 2017 08:35:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315395 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2017 08:35:29 -0000 Author: mjg Date: Thu Mar 16 08:35:27 2017 New Revision: 315395 URL: https://svnweb.freebsd.org/changeset/base/315395 Log: MFC r309784,r309783: Use a consistent snapshot of the lock state in owner_mtx(). == Return a non-NULL owner only if the lock is exclusively held in owner_sx(). Fix some whitespace bugs while here. ============ While here the correct commit message for the previous commit: MFC r313855 r313865 r313875 r313877 r313878 r313901 r313908 r313928 r313944 r314185 r314476 r314187 locks: let primitives for modules unlock without always goging to the slsow path It is only needed if the LOCK_PROFILING is enabled. It has to always check if the lock is about to be released which requires an avoidable read if the option is not specified.. == sx: fix compilation on UP kernels after r313855 sx primitives use inlines as opposed to macros. Change the tested condition to LOCK_DEBUG which covers the case, but is slightly overzelaous. == mtx: microoptimize lockstat handling in __mtx_lock_sleep This saves a function call and multiple branches after the lock is acquired. == mtx: restrict r313875 to kernels without LOCK_PROFILING == mtx: get rid of file/line args from slow paths if they are unused This denotes changes which went in by accident in r313877. On most production kernels both said parameters are zeroed and have nothing reading them in either __mtx_lock_sleep or __mtx_unlock_sleep. Thus this change stops passing them by internal consumers which this is the case. Kernel modules use _flags variants which are not affected kbi-wise. == sx: fix mips builld after r313855 The namespace in this file really needs cleaning up. In the meantime let inline primitives be defined as long as LOCK_DEBUG is not enabled. == mtx: plug the 'opts' argument when not used git-svn-id: svn+ssh://svn.freebsd.org/base/head@313908 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f == locks: clean up trylock primitives In particular thius reduces accesses of the lock itself. == locks: make trylock routines check for 'unowned' value Since fcmpset can fail without lock contention e.g. on arm, it was possible to get spurious failures when the caller was expecting the primitive to succeed. == mtx: microoptimize lockstat handling in spin mutexes and thread lock While here make the code compilablle on kernels with LOCK_PROFILING but without KDTRACE_HOOKS. == KDTRACE_HOOKS isn't guaranteed to be defined. Change to check to see if it is defined or not rather than if it is non-zero. == locks: fix compilation with KTR wihout KTR_LOCKS While here wrap the overly long line. Modified: stable/11/sys/kern/kern_mutex.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_mutex.c ============================================================================== --- stable/11/sys/kern/kern_mutex.c Thu Mar 16 08:29:09 2017 (r315394) +++ stable/11/sys/kern/kern_mutex.c Thu Mar 16 08:35:27 2017 (r315395) @@ -211,10 +211,13 @@ unlock_spin(struct lock_object *lock) int owner_mtx(const struct lock_object *lock, struct thread **owner) { - const struct mtx *m = (const struct mtx *)lock; + const struct mtx *m; + uintptr_t x; - *owner = mtx_owner(m); - return (mtx_unowned(m) == 0); + m = (const struct mtx *)lock; + x = m->mtx_lock; + *owner = (struct thread *)(x & ~MTX_FLAGMASK); + return (x != MTX_UNOWNED); } #endif