From nobody Mon Apr 13 04:01:50 2026 X-Original-To: dev-commits-src-all@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 4fvDHm0SlZz6YCSG for ; Mon, 13 Apr 2026 04:01:56 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fvDHl1f18z3wVk for ; Mon, 13 Apr 2026 04:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776052915; 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=xDDJn9sxDkQK74xToW+t+7OyJn3ti1IE4+Es2e6d0T8=; b=b9xbJMnoqDK5bZcz38G5p/dUTKV4Lpf1AY7mFYJaflIAsj3YDU1YMpRvPAs4PP8Q8ooVE+ 3HLzZcn0Oqm4lZH/x2NmBo6fbnbbOXID6b24N3gj3ZXI1GqlmjqYyA8/U4kzDzNxUqj2wt 3YdBSfpEFhUrJwUEEdBxCYaUxuVDs9HEPyLxpvkvPecILcHJB1cMVzMRMCuMjUKNhsujIS VVJaDG4+42n5OKmO9aq0s6pUD1SC1+igE/mrh9AfSfFHJq6nOJX2jv2I+saZNDvcETTq9k hdn1exHYIreVe17oRQxd7Z3rBnp78hl+vHrzBpLtn8YJDvm5LFBSpjWKjfeBKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776052915; a=rsa-sha256; cv=none; b=pOhYSuryhoUAyPDHkn7M3pZcsNZs42Foo+mObALMNvs4XVI0HeKtoTcgyqkvRld7vuYvvg X25Y3gKQsKW2D7V5pxWqDx25d8Igoewv3FPnKbidjQgY3wg1VKiyWvSNPlZr3YwmB6iHJR 8fPapwLP11hrZmaEjIOt891XRQ2jMyLjsMGPxK+0hTDV9M8C6yeTC9b+YeQ3YOtyjjct1v clZrmVf48W6sS8f0Te6y10mxiFe0bZU1eth18gKpMfTzPGW2G+dLnTwlfN9a2M97LeNtwS 7wDWHQIJmyL7JnTpoLCxrWLq4BrP1Y3nVI4BmGAAFKO9w/WSplqKb0LiDIC++A== 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=1776052915; 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=xDDJn9sxDkQK74xToW+t+7OyJn3ti1IE4+Es2e6d0T8=; b=ptnQcVKThaE+yxM7oABeuOxDN9YouDr0ogIAL8AVw5vwNSjMMyyH2IsBCGHSH55W/K7QeJ O31f1PasW7sBi3p6E8L/RCAdeIcF+aoMN14O3ISuXA1ztCHUFobGtUwLpgwwyL23zodNL3 iLePqmt6A5LHnKJrrk684/emsQj5mwguPwXKPAL8blURGbCylHk0BQ24HbPeSjpezgiDUr Q12mELr9WrpPmlgYyOiEWqofA5RnkklZMjLX6yfQ6DnJ390Rh5p2BgRAhzdtN+ClP4s9Nl +6ZZPbBVDYgG8/pREkA2GFlI7EfkbTraFsrefGFG2IOlcCbdjuzqs+dsBaYmxQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fvDHl0xzTznCR for ; Mon, 13 Apr 2026 04:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1cfef by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 13 Apr 2026 04:01:50 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: e6d30726b97a - stable/15 - kqueue: simplify knote_fdclose() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e6d30726b97a449b584cf65447a983d452f9511a Auto-Submitted: auto-generated Date: Mon, 13 Apr 2026 04:01:50 +0000 Message-Id: <69dc6aae.1cfef.5fe91daf@gitrepo.freebsd.org> The branch stable/15 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=e6d30726b97a449b584cf65447a983d452f9511a commit e6d30726b97a449b584cf65447a983d452f9511a Author: Kyle Evans AuthorDate: 2026-04-01 22:30:48 +0000 Commit: Kyle Evans CommitDate: 2026-04-13 03:12:19 +0000 kqueue: simplify knote_fdclose() The influx logic in knote_fdclose() is a little misguided, the resulting wakeup() call should always be redundant: knote_drop_detached() will always issue a wakeup before it returns, so anything waiting on *that* knote that had entered fluxwait should have been woken up then. This is the obvious divergence from the other influx/wakeup pattern in the implementation, which will kn_influx-- and then issue the wakeup after it has processed all of the knotes it can make progress on. While we're here, the kq_knlist cannot shrink, so we can avoid that condition in the loop and avoid potentially excessive wakeups from fluxwait on kqueues that we didn't touch. Reviewed by: kib, markj (cherry picked from commit ff1050d2a366bd288a6ebbf63f98003272513f92) --- sys/kern/kern_event.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 3872fb5862c5..245a18738d86 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -2838,7 +2838,6 @@ knote_fdclose(struct thread *td, int fd) struct filedesc *fdp = td->td_proc->p_fd; struct kqueue *kq; struct knote *kn; - int influx; FILEDESC_XLOCK_ASSERT(fdp); @@ -2848,22 +2847,25 @@ knote_fdclose(struct thread *td, int fd) */ TAILQ_FOREACH(kq, &fdp->fd_kqlist, kq_list) { KQ_LOCK(kq); + if (kq->kq_knlistsize <= fd || + SLIST_EMPTY(&kq->kq_knlist[fd])) { + KQ_UNLOCK(kq); + continue; + } -again: - influx = 0; - while (kq->kq_knlistsize > fd && - (kn = SLIST_FIRST(&kq->kq_knlist[fd])) != NULL) { + while ((kn = SLIST_FIRST(&kq->kq_knlist[fd])) != NULL) { if (kn_in_flux(kn)) { - /* someone else might be waiting on our knote */ - if (influx) - wakeup(kq); + /* + * Wait for this knote to stabilize, it could be + * 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); - goto again; + continue; } kn_enter_flux(kn); KQ_UNLOCK(kq); - influx = 1; knote_drop(kn, td); KQ_LOCK(kq); }