From owner-dev-commits-src-main@freebsd.org Thu Aug 5 22:51:57 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB41D66BCC0; Thu, 5 Aug 2021 22:51:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GgkPn4rLgz4crB; Thu, 5 Aug 2021 22:51:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E7FD22274; Thu, 5 Aug 2021 22:51:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 175MpvGd090850; Thu, 5 Aug 2021 22:51:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 175MpvX7090849; Thu, 5 Aug 2021 22:51:57 GMT (envelope-from git) Date: Thu, 5 Aug 2021 22:51:57 GMT Message-Id: <202108052251.175MpvX7090849@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: 1b97a054f3ac - main - tsleep: Add a PNOLOCK flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1b97a054f3acaf13a5c8361b7b80e10ad16257b9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2021 22:51:57 -0000 The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=1b97a054f3acaf13a5c8361b7b80e10ad16257b9 commit 1b97a054f3acaf13a5c8361b7b80e10ad16257b9 Author: Andrew Gallatin AuthorDate: 2021-08-05 21:16:30 +0000 Commit: Andrew Gallatin CommitDate: 2021-08-05 21:16:30 +0000 tsleep: Add a PNOLOCK flag Add a PNOLOCK flag so that, in the race circumstance where wakeup races are externally mitigated, tsleep() can be called with a sleep time of 0 without triggering an an assertion. Reviewed by: jhb Sponsored by: Netflix --- sys/kern/kern_synch.c | 3 ++- sys/sys/param.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 793c5309a30b..7bf5193fb7b1 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -148,7 +148,8 @@ _sleep(const void *ident, struct lock_object *lock, int priority, #endif WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, "Sleeping on \"%s\"", wmesg); - KASSERT(sbt != 0 || mtx_owned(&Giant) || lock != NULL, + KASSERT(sbt != 0 || mtx_owned(&Giant) || lock != NULL || + (priority & PNOLOCK) != 0, ("sleeping without a lock")); KASSERT(ident != NULL, ("_sleep: NULL ident")); KASSERT(TD_IS_RUNNING(td), ("_sleep: curthread not running")); diff --git a/sys/sys/param.h b/sys/sys/param.h index f842b344e9f9..8864063e3d9b 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -246,7 +246,8 @@ #define PRIMASK 0x0ff #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ -#define PRILASTFLAG 0x200 /* Last flag defined above */ +#define PNOLOCK 0x400 /* OR'd with pri to allow sleeping w/o a lock */ +#define PRILASTFLAG 0x400 /* Last flag defined above */ #define NZERO 0 /* default "nice" */