From nobody Thu Aug 6 15:01:37 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hG9Tt4Dg5z6nB7s for ; Thu, 06 Aug 2026 15:01:38 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hG9Tt0Hftz3Dlm for ; Thu, 06 Aug 2026 15:01:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786028498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WfzLtfdT7V9jPAxjO/dXe5IElXOFABc85wCq5GC8ObE=; b=PUQGvE02tvU7oerf7vNBkzvdhSf0ZAtTgwWq2piEEv1lK1ysvN/aQlv1cw6oZKpOt0k9GX LbI57kqUH2y851PYIEX0PrlkoGbkZFHrcZ9SAKLnvrs5jLznxjyjEaI1PXbRhI8stslqit qN7KlxyJu5ubAkLZgFQCo05fMbKErbTjAjiEl7AtOUxTqxDbNxbbUlTD93kBdThwftAeQ2 2YnuYWMP5AJzW70bbZUKv0xLx5cTaRwrvKfROriTyN36qIc/UovVEnblOfAYSK+9AXD+ie Hdjb63yQQRdwDsxtg0Hy1l23+2OM5qXz9kDtpWxSrKuV1JScNwygYjopDTgJkg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786028498; a=rsa-sha256; cv=none; b=Eh5eIDCQQGBsDnxmXRCPP5Xh8SlCL9ADjVdRBLqTZbc1pfmFhQ94xJzcgz9i8SuV4f6LPr n6hzPiQqnXwIqBSl5ly6lithAK28pssj68q7tebnSb9R4LYwrpD5I9ajqs7w/mwsyIFGR3 U1u3xunhAQ7hV0svPO70fw8aOLL1pbx/XxWrk66YW6mnUpPimPczUVkxYiGdnRD8eZ427O LUQUC34UwfUuNT744Rd/Sk0qZgNZA4WPo4VKQuENjztBMMyc0ZVusuvLuYcuzVOFLRisIe DZm2Qlg2jmiAkHeTFsQPGqv58oGU06nga6XN5VGY3qdSiQM6Ycqr15Rycp4hdA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786028498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WfzLtfdT7V9jPAxjO/dXe5IElXOFABc85wCq5GC8ObE=; b=kdwBFGghITF8vZ6FM651a1ztBBR8H8kj4xJkfO8I4Ri+zinvkdz9jIMJZmtZi+j83cBswy pHPj0rVeAd++sL64scURwILgFKhbRZGxbnRHxIt/9FYSIfT/FckCUFmZuuJ8+xEAmr2kHx EotKlDCZtuUflAkpYttPOLkfxB3MYJpqbHFbF3rIi7bUvcN9R8BYHjclkjTom3J1wTMOyq 7mBRSaHR0RDhaAj2XhaRp6ffnRQrYuUkjw2G9MurN1x/tFyIcltmkFo7Ydn2R4nv5jcPi5 7bbzUuUY+MKWTQRXAN8zuRCMzGzP0qrkVhl+aQd6pWRDPQoQA7YFX3J8lCJBJQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hG9Ts6S5xz9XK for ; Thu, 06 Aug 2026 15:01:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 46d8a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 06 Aug 2026 15:01:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 31d9493fbb2c - stable/15 - kqueue: Add a helper macro for sleeping on in-flux knotes List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 31d9493fbb2c7e38dc151bce30a4cd26efa680ae Auto-Submitted: auto-generated Date: Thu, 06 Aug 2026 15:01:37 +0000 Message-Id: <6a74a1d1.46d8a.56722aba@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=31d9493fbb2c7e38dc151bce30a4cd26efa680ae commit 31d9493fbb2c7e38dc151bce30a4cd26efa680ae Author: Mark Johnston AuthorDate: 2026-07-27 23:12:16 +0000 Commit: Mark Johnston CommitDate: 2026-08-06 13:24:43 +0000 kqueue: Add a helper macro for sleeping on in-flux knotes Other in-flux operations are implemented by this set of macros, so we should do the same for sleeping. No functional change intended. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58443 (cherry picked from commit 1f4b0ea4f3eb1b8a885eff8bd0d332156f0c3e1f) --- sys/kern/kern_event.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index cbed1073fa58..0a02642cccae 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -257,6 +257,14 @@ SYSCTL_UINT(_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW, wakeup((kq)); \ } \ } while (0) +#define KQ_FLUX_SLEEP_WMESG(kq, kn, flags, wmesg) do { \ + KASSERT((kn)->kn_kq == (kq), \ + ("%s: knote %p not on kqueue %p", __func__, kn, kq)); \ + (kq)->kq_state |= KQ_FLUXWAIT; \ + msleep((kq), &(kq)->kq_lock, PSOCK | (flags), (wmesg), 0); \ +} while (0) +#define KQ_FLUX_SLEEP(kq, kn, flags) \ + KQ_FLUX_SLEEP_WMESG(kq, kn, flags, "kqfluxwt") #define KQ_UNLOCK_FLUX(kq) do { \ KQ_FLUX_WAKEUP(kq); \ mtx_unlock(&(kq)->kq_lock); \ @@ -1789,8 +1797,7 @@ findkn: FILEDESC_XUNLOCK(td->td_proc->p_fd); filedesc_unlock = 0; } - kq->kq_state |= KQ_FLUXWAIT; - msleep(kq, &kq->kq_lock, PSOCK | PDROP, "kqflxwt", 0); + KQ_FLUX_SLEEP(kq, kn, PDROP); if (fp != NULL) { fdrop(fp, td); fp = NULL; @@ -2187,9 +2194,7 @@ retry: influx = 0; KQ_FLUX_WAKEUP(kq); } - kq->kq_state |= KQ_FLUXWAIT; - error = msleep(kq, &kq->kq_lock, PSOCK, - "kqflxwt", 0); + KQ_FLUX_SLEEP(kq, kn, 0); continue; } @@ -2423,8 +2428,7 @@ kqueue_drain(struct kqueue *kq, struct thread *td) for (i = 0; i < kq->kq_knlistsize; i++) { while ((kn = SLIST_FIRST(&kq->kq_knlist[i])) != NULL) { if (kn_in_flux(kn)) { - kq->kq_state |= KQ_FLUXWAIT; - msleep(kq, &kq->kq_lock, PSOCK, "kqclo1", 0); + KQ_FLUX_SLEEP_WMESG(kq, kn, 0, "kqclo1"); continue; } kn_enter_flux(kn); @@ -2437,9 +2441,8 @@ kqueue_drain(struct kqueue *kq, struct thread *td) for (i = 0; i <= kq->kq_knhashmask; i++) { while ((kn = SLIST_FIRST(&kq->kq_knhash[i])) != NULL) { if (kn_in_flux(kn)) { - kq->kq_state |= KQ_FLUXWAIT; - msleep(kq, &kq->kq_lock, PSOCK, - "kqclo2", 0); + KQ_FLUX_SLEEP_WMESG(kq, kn, 0, + "kqclo2"); continue; } kn_enter_flux(kn); @@ -2834,8 +2837,7 @@ knlist_cleardel(struct knlist *knl, struct thread *td, int islocked, int killkn) KQ_LOCK(kq); KASSERT(kn_in_flux(kn), ("knote removed w/o list lock")); knl->kl_unlock(knl->kl_lockarg); - kq->kq_state |= KQ_FLUXWAIT; - msleep(kq, &kq->kq_lock, PSOCK | PDROP, "kqkclr", 0); + KQ_FLUX_SLEEP_WMESG(kq, kn, PDROP, "kqkclr"); kq = NULL; knl->kl_lock(knl->kl_lockarg); } @@ -2881,8 +2883,7 @@ knote_fdclose(struct thread *td, int fd) * the case that it's in the process of being * dropped anyways. */ - kq->kq_state |= KQ_FLUXWAIT; - msleep(kq, &kq->kq_lock, PSOCK, "kqflxwt", 0); + KQ_FLUX_SLEEP(kq, kn, 0); continue; } kn_enter_flux(kn); @@ -2946,8 +2947,7 @@ knote_drop_detached(struct knote *kn, struct thread *td) kn, kn->kn_influx)); if (kn->kn_influx == 1) break; - kq->kq_state |= KQ_FLUXWAIT; - msleep(kq, &kq->kq_lock, PSOCK, "kqflxwt", 0); + KQ_FLUX_SLEEP(kq, kn, 0); } MPASS(kn->kn_kq == kq);