From nobody Thu Sep 03 16:29:51 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 4hbQ6s3cm3z6rVQH for ; Thu, 03 Sep 2026 16:29: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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hbQ6r6y81z4PrP for ; Thu, 03 Sep 2026 16:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788452997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ii80xkhnwX/Ndn3jWS58WfNQx0z7bTXAgndI7JiK7t8=; b=IX0T1dKdFY2pK/o6f16N2gZvgb3/5+bmJ/XUkEbeon83JwkE4MI6U+rtAMQYwQ0WW4KyH7 q2p9LGGb6lhnW2O/QPJy/7q35evL0yYtpBH9xJKzPWgt7n6Twuwu/I774wFEwjC8vEcxlb kKqNbupzCCkgxJ4OSjjyDy67zqjuRU6OXqN4bro9zWT9pA7to2hBx6a0hsWg2OzVy+ZLW0 /nGnXqHnYoVs71veHSZXGFBXwdvq7QPmFDI2U02cN69oLlTxd/K237jDpddcqYNs6vhdaP ii2L7icwYDycvTDYxm/raO+t310c77JbnBD0ujjjXnWpMBbB5zwrkF+UtKDCrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788452997; a=rsa-sha256; cv=none; b=DXZlD7jAVIIFBBqN90g0VQOdN72HboFLOoXQ0GoAoNFppZSVn7lUVNk9QeDMt8sFkAX5I9 xBaYuWEBhObD4KPay2ZnPuVz4+kfy7+N5FmMC349RA4Q/5ZhL3h4bDtFj0P76LboV1Ibzs 1OQtr1bDiSp/tOO6kudFMV3qi6R9Psu7CXqFSUT0tr6JjyJMvR4UbEB8sABletF+wTYpy/ qwtcRxVBRuNC/kXshOQtCBjuk7KzgwfYTniDm0ECxquQjVaF2AkCncXqjVyhlK66ui5g5u gVpbGQ6Llfp2hI1RstlJ/kHmEcoAJCDOXxXmiZR1GXlIJYkp0oJyejYKmy8Buw== 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=1788452997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ii80xkhnwX/Ndn3jWS58WfNQx0z7bTXAgndI7JiK7t8=; b=OqQUZXLfW08ws+i3NkFURR+xLldhsDg6RPto5OSQ08+5aUzPtXFYX587e7xqzGlYlZYz0W 4RY1l8kTolONbg3xzW5KYpjnB3ka1pTxZoN1x71DWgazRtpQ3o9wmTtdgwP9yTSy9+uRxm rDfxOltgcEkKb/PtP3e/Fgf6koVt+HezdT1+IiKpW2DdQWDJAkXXSNyHzqq/5IaHRLIaBp MFolw7U0WkIEHlJmUbfxqBnVoZpL95vR5XHC0u1E2ss/GCe8NwXjgh+donsk205OGDiI0c yNWomiE04GYYLSZCBI1nyXTjEl9AgW2Zi7/aO5heNbgO04DdY4rYNFGhOqN82A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hbQ6r5twFz5W2 for ; Thu, 03 Sep 2026 16:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 388b9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 03 Sep 2026 16:29:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Andre Silva From: Mitchell Horne Subject: git: 92cf9e36ecf9 - stable/15 - hwpmc: fix false runcount assertion in user callchain capture 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 92cf9e36ecf937618a5b977b53027a4d28efe0f2 Auto-Submitted: auto-generated Date: Thu, 03 Sep 2026 16:29:51 +0000 Message-Id: <6a99a07f.388b9.3be77fa6@gitrepo.freebsd.org> The branch stable/15 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=92cf9e36ecf937618a5b977b53027a4d28efe0f2 commit 92cf9e36ecf937618a5b977b53027a4d28efe0f2 Author: Andre Silva AuthorDate: 2026-08-11 16:16:20 +0000 Commit: Mitchell Horne CommitDate: 2026-09-03 16:27:28 +0000 hwpmc: fix false runcount assertion in user callchain capture pmc_capture_user_callchain() checks a PMC's runcount before walking the user stack, but reads it without holding the spinlock that protects it. hardclock() can run on the same CPU during the capture and drop the runcount to zero in between, tripping the assertion and panicking INVARIANTS kernels under load. Move the check inside the existing spinlock, right where the code already confirms the sample is still valid. No functional change on kernels built without INVARIANTS. Signed-off-by: Andre Silva Reviewed by: mhorne MFC after: 1 week Sponsored by: AMD Differential Revision: https://reviews.freebsd.org/D58571 (cherry picked from commit 66118c3f1011d7852bce8b659899179a83781897) --- sys/dev/hwpmc/hwpmc_mod.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 98ef14885c10..21effa80a4bb 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -4809,9 +4809,6 @@ restart: KASSERT(pm->pm_flags & PMC_F_CALLCHAIN, ("[pmc,%d] Retrieving callchain for PMC that doesn't " "want it", __LINE__)); - KASSERT(counter_u64_fetch(pm->pm_runcount) > 0, - ("[pmc,%d] runcount %ju", __LINE__, - (uintmax_t)counter_u64_fetch(pm->pm_runcount))); if (ring == PMC_UR) { nsamples = ps->ps_nsamples_actual; @@ -4838,6 +4835,10 @@ restart: * Verify that the sample hasn't been dropped in the meantime. */ if (ps->ps_nsamples == PMC_USER_CALLCHAIN_PENDING) { + KASSERT(counter_u64_fetch(pm->pm_runcount) > 0, + ("[pmc,%d] runcount %ju", __LINE__, + (uintmax_t)counter_u64_fetch(pm->pm_runcount))); + ps->ps_nsamples = nsamples; /* * If we couldn't get a sample, simply drop the