From owner-svn-src-all@freebsd.org Sun Jun 24 18:57:07 2018 Return-Path: Delivered-To: svn-src-all@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 4F2A71009844; Sun, 24 Jun 2018 18:57:07 +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 EC7FE72B8D; Sun, 24 Jun 2018 18:57:06 +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 C6D782296D; Sun, 24 Jun 2018 18:57:06 +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 w5OIv6Ii006409; Sun, 24 Jun 2018 18:57:06 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5OIv6dX006407; Sun, 24 Jun 2018 18:57:06 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201806241857.w5OIv6dX006407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Sun, 24 Jun 2018 18:57:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335605 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 335605 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jun 2018 18:57:07 -0000 Author: mmacy Date: Sun Jun 24 18:57:06 2018 New Revision: 335605 URL: https://svnweb.freebsd.org/changeset/base/335605 Log: fix assert and conditionally allow mutexes to be held across epoch_wait_preempt Modified: head/sys/kern/subr_epoch.c head/sys/sys/epoch.h Modified: head/sys/kern/subr_epoch.c ============================================================================== --- head/sys/kern/subr_epoch.c Sun Jun 24 15:22:38 2018 (r335604) +++ head/sys/kern/subr_epoch.c Sun Jun 24 18:57:06 2018 (r335605) @@ -375,9 +375,11 @@ epoch_block_handler_preempt(struct ck_epoch *global __ struct turnstile *ts; struct lock_object *lock; int spincount, gen; + int locksheld __unused; record = __containerof(cr, struct epoch_record, er_record); td = curthread; + locksheld = td->td_locks; spincount = 0; counter_u64_add(block_count, 1); if (record->er_cpuid != curcpu) { @@ -470,8 +472,8 @@ epoch_block_handler_preempt(struct ck_epoch *global __ turnstile_unlock(ts, lock); thread_lock(td); critical_exit(); - KASSERT(td->td_locks == 0, - ("%d locks held", td->td_locks)); + KASSERT(td->td_locks == locksheld, + ("%d extra locks held", td->td_locks - locksheld)); } } /* @@ -499,23 +501,20 @@ epoch_wait_preempt(epoch_t epoch) int old_cpu; int old_pinned; u_char old_prio; -#ifdef INVARIANTS - int locks; + int locks __unused; - locks = curthread->td_locks; -#endif - MPASS(cold || epoch != NULL); INIT_CHECK(epoch); - - MPASS(epoch->e_flags & EPOCH_PREEMPT); - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "epoch_wait() can sleep"); - td = curthread; +#ifdef INVARIANTS + locks = curthread->td_locks; + MPASS(epoch->e_flags & EPOCH_PREEMPT); + if ((epoch->e_flags & EPOCH_LOCKED) == 0) + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, + "epoch_wait() can be long running"); KASSERT(td->td_epochnest == 0, ("epoch_wait() in the middle of an epoch section")); +#endif thread_lock(td); - DROP_GIANT(); old_cpu = PCPU_GET(cpuid); Modified: head/sys/sys/epoch.h ============================================================================== --- head/sys/sys/epoch.h Sun Jun 24 15:22:38 2018 (r335604) +++ head/sys/sys/epoch.h Sun Jun 24 18:57:06 2018 (r335605) @@ -39,6 +39,7 @@ struct epoch; typedef struct epoch *epoch_t; #define EPOCH_PREEMPT 0x1 +#define EPOCH_LOCKED 0x2 extern epoch_t global_epoch; extern epoch_t global_epoch_preempt;