From nobody Tue Sep 9 03:06:13 2025 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 4cLTH94NFSz66FfM; Tue, 09 Sep 2025 03:06:13 +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" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cLTH93Cj3z3vmF; Tue, 09 Sep 2025 03:06:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757387173; 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=YSwWu3JDwSh/d93iBnGMUSMYlBxUkP5SstZE0kVu6Xo=; b=rxW2ahPJOqrh+dgYwJWVbSv+KkbBN0VwSt5Ns4QpPiuSQvaCN1nNlJGWB/yKvFhqMlyt1h JkwFUIhZivh1C9ky6n3OH32j+WPioGrVjNnjrekNc2oXgmhWX9rc7xTh+XPBAsb7QXf9kQ wB/jEJbenjZD4G93x4Gtm4Opypa9xdSP98IDWuyoVHF8SkOZfpYjTUcm8Il5oaEQgE3zNL D9NsA3QJIl7hC8TT2Tz3dE7PAtF8R+CZ8DjD9r5lPGOosi7I++1sLUZpsp+xbcaEeUo/V3 HnwYLW9zpPaSb87Db3D5/hRkaR+ObpdebFDOu3iMGje+Tn3xm66CoAyfeU7p/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757387173; 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=YSwWu3JDwSh/d93iBnGMUSMYlBxUkP5SstZE0kVu6Xo=; b=c1XzE+Qt1cEFfDeWxoYjx+bwU3rxowJJfUNr81LntZBZwkO/OfFxvhWWPfkta+Y80NEEuX YQtIwo4tILgb7r8KowCrP2LQK6SygmXoIFa0Rnr0rYZj7T5xDw0dBecHsasOqwVHt1Of/A Nb9P1czQmRdFRep1ixYXxinjE0CBzwxh7lmuNCn+tyz15PPLSMeDHcrtAMY77urK7zS5HV XvPdz0InYWnJuRfBXCPSftHuV8e7yHCcRcfokHtQwnwy6NUEobX8534DrDw+jNSuwHp3v5 +VYYvDxZVVtMugMhh4qNB0mxupd56G+Qj6U3Yeish0rAxfip8EFePE4IIZ1hag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757387173; a=rsa-sha256; cv=none; b=F4gdXQZwBmWjMMcsk0EIbzpKigcEv1WfYTsCLyDWrfJflz5UMGnoFKJ9wziCakGCWMdgq6 TTPDfbFODj/Pt22q2glg+rV2F+6t73YhzlIpVkmgI4w4xesSLrm69hAwWQfjDjtIEQAmIZ GQthPX/uTBLts09PUFAIHK0/+gGw8JB+kZcRcD9uVMGZDdziM+YS/eV5QEIXej4Ul74qB9 XVuyDaDRjDpvhJcaEZLAGoUiyzVShhfhn/eqr8FWUEXGdp/cHA4sZ52OHrL50nJ2n53bSn XoNwdm2UaIlKC+d70IX5lLHMFgKBXeWYck9sgadqmVhjdhv49+GHfOuD//huwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cLTH92W2Qz3Cr; Tue, 09 Sep 2025 03:06:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58936DAb093852; Tue, 9 Sep 2025 03:06:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58936D5Y093849; Tue, 9 Sep 2025 03:06:13 GMT (envelope-from git) Date: Tue, 9 Sep 2025 03:06:13 GMT Message-Id: <202509090306.58936D5Y093849@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f51d7d5139a7 - main - kern_thr_exit(): clear kASTs in advance 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f51d7d5139a76d225c9f537bd948525ababdef0c Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f51d7d5139a76d225c9f537bd948525ababdef0c commit f51d7d5139a76d225c9f537bd948525ababdef0c Author: Konstantin Belousov AuthorDate: 2025-09-08 03:43:09 +0000 Commit: Konstantin Belousov CommitDate: 2025-09-09 02:51:08 +0000 kern_thr_exit(): clear kASTs in advance PR: 289204 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D52421 --- sys/kern/kern_thr.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 0e8c2b9f362e..4329959a2ef4 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -346,6 +346,17 @@ kern_thr_exit(struct thread *td) p = td->td_proc; + /* + * Clear kernel ASTs in advance of selecting the last exiting + * thread and acquiring schedulers locks. It is fine to + * clear the ASTs here even if we are not going to exit after + * all. On the other hand, leaving them pending could trigger + * execution in subsystems in a context where they are not + * prepared to handle top kernel actions, even in execution of + * an unrelated thread. + */ + ast_kclear(td); + /* * If all of the threads in a process call this routine to * exit (e.g. all threads call pthread_exit()), exactly one