From owner-svn-src-head@freebsd.org Mon Jun 19 21:09:52 2017 Return-Path: Delivered-To: svn-src-head@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 13314DA4D27; Mon, 19 Jun 2017 21:09:52 +0000 (UTC) (envelope-from markj@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 E17C3846A3; Mon, 19 Jun 2017 21:09:51 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5JL9oT7043000; Mon, 19 Jun 2017 21:09:50 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5JL9o7f042997; Mon, 19 Jun 2017 21:09:50 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201706192109.v5JL9o7f042997@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 19 Jun 2017 21:09:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320124 - head/sys/kern X-SVN-Group: head 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.23 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: Mon, 19 Jun 2017 21:09:52 -0000 Author: markj Date: Mon Jun 19 21:09:50 2017 New Revision: 320124 URL: https://svnweb.freebsd.org/changeset/base/320124 Log: Fix the !TD_IS_IDLETHREAD(curthread) locking assertions. Most of the lock slowpaths assert that the calling thread isn't an idle thread. However, this may not be true if the system has panicked, and in some cases the assertion appears before a SCHEDULER_STOPPED() check. MFC after: 3 days Sponsored by: Dell EMC Isilon Modified: head/sys/kern/kern_mutex.c head/sys/kern/kern_rwlock.c head/sys/kern/kern_sx.c Modified: head/sys/kern/kern_mutex.c ============================================================================== --- head/sys/kern/kern_mutex.c Mon Jun 19 20:48:00 2017 (r320123) +++ head/sys/kern/kern_mutex.c Mon Jun 19 21:09:50 2017 (r320124) @@ -233,7 +233,8 @@ __mtx_lock_flags(volatile uintptr_t *c, int opts, cons m = mtxlock2mtx(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() || + !TD_IS_IDLETHREAD(curthread), ("mtx_lock() by idle thread %p on sleep mutex %s @ %s:%d", curthread, m->lock_object.lo_name, file, line)); KASSERT(m->mtx_lock != MTX_DESTROYED, @@ -390,7 +391,7 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c m = mtxlock2mtx(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td), ("mtx_trylock() by idle thread %p on sleep mutex %s @ %s:%d", curthread, m->lock_object.lo_name, file, line)); KASSERT(m->mtx_lock != MTX_DESTROYED, Modified: head/sys/kern/kern_rwlock.c ============================================================================== --- head/sys/kern/kern_rwlock.c Mon Jun 19 20:48:00 2017 (r320123) +++ head/sys/kern/kern_rwlock.c Mon Jun 19 21:09:50 2017 (r320124) @@ -269,7 +269,8 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *fi rw = rwlock2rw(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() || + !TD_IS_IDLETHREAD(curthread), ("rw_wlock() by idle thread %p on rwlock %s @ %s:%d", curthread, rw->lock_object.lo_name, file, line)); KASSERT(rw->rw_lock != RW_DESTROYED, @@ -305,7 +306,7 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file rw = rwlock2rw(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td), ("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d", curthread, rw->lock_object.lo_name, file, line)); KASSERT(rw->rw_lock != RW_DESTROYED, @@ -615,7 +616,8 @@ __rw_rlock(volatile uintptr_t *c, const char *file, in td = curthread; rw = rwlock2rw(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td), + KASSERT(kdb_active != 0 || SCHEDULER_STOPPED_TD(td) || + !TD_IS_IDLETHREAD(td), ("rw_rlock() by idle thread %p on rwlock %s @ %s:%d", td, rw->lock_object.lo_name, file, line)); KASSERT(rw->rw_lock != RW_DESTROYED, @@ -815,7 +817,6 @@ _rw_runlock_cookie(volatile uintptr_t *c, const char * TD_LOCKS_DEC(curthread); } - /* * This function is called when we are unable to obtain a write lock on the Modified: head/sys/kern/kern_sx.c ============================================================================== --- head/sys/kern/kern_sx.c Mon Jun 19 20:48:00 2017 (r320123) +++ head/sys/kern/kern_sx.c Mon Jun 19 21:09:50 2017 (r320124) @@ -295,7 +295,8 @@ _sx_xlock(struct sx *sx, int opts, const char *file, i uintptr_t tid, x; int error = 0; - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() || + !TD_IS_IDLETHREAD(curthread), ("sx_xlock() by idle thread %p on sx %s @ %s:%d", curthread, sx->lock_object.lo_name, file, line)); KASSERT(sx->sx_lock != SX_LOCK_DESTROYED, @@ -332,7 +333,7 @@ sx_try_xlock_(struct sx *sx, const char *file, int lin if (SCHEDULER_STOPPED_TD(td)) return (1); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td), ("sx_try_xlock() by idle thread %p on sx %s @ %s:%d", curthread, sx->lock_object.lo_name, file, line)); KASSERT(sx->sx_lock != SX_LOCK_DESTROYED, @@ -1030,7 +1031,8 @@ _sx_slock(struct sx *sx, int opts, const char *file, i uintptr_t x; int error; - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), + KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() || + !TD_IS_IDLETHREAD(curthread), ("sx_slock() by idle thread %p on sx %s @ %s:%d", curthread, sx->lock_object.lo_name, file, line)); KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,