From nobody Tue Aug 11 16:22:42 2026 X-Original-To: dev-commits-src-main@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 4hKH361vBpz6nxlk for ; Tue, 11 Aug 2026 16:22:42 +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 4hKH3614dbz3MRM for ; Tue, 11 Aug 2026 16:22:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786465362; 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=olqfeoKAdZ3VkiUJ+KIYTzu0ha1ZB9Yd2OTja4KsOJA=; b=srEV2uU7l4RdHGAFCzGu1l+IfoQNv+cP4qnwrarEZksM2F3LB4UVsYD61IWrbfVOG92Qtg bWq+4kNOI42oFdqTnEtCdYuf0aHCYeMVQpGgEvflETV4K3pV/TRuV4sGiBXgNq7FRuZgn/ zFtHLCkFje5yAG0jI3/7h7xQkuaDxW0wMLOnTND6kKGUFUeXi8ch/eQQ633S1wKUAS5k56 vFpXe4eNqLqsY5QDoEE6SFlq8RoqOJwcIIVRAXMD57T1esgvWpBxh/CxOuBHPJh9lvRxJL cgipajS0wfV5WZDEBOFO4xBfEnrQawIvL7IN6ojT/c9TupoGY/Qc6c97RG9XSA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786465362; a=rsa-sha256; cv=none; b=PMVIy3l2nrUKJb59B3WGpoqP9Hw/5C9uiomK+96OQr5hMFy7vkX93367FmnqiagrG9A9ON kJRyjxYwEW+2XRqHqtrfyY+eimP4MKYUQqMWYCRVwK+1ykCbT1Ck1pzBx6N9BMbKMmH2Lj cTeihwflo3M4e2Yt10atPGhrp47qq0O3eg/jVfRVLbxOJYnPUweFoJhRhdGTzyPE/0SxjH Uf9J9Z95lJjSVYLCWN8IosmQei7HyJ/lMcLbEk+tRzZChqYDmUcJyI3c+4Yk1QKKkYQkYb mMpQOiWvfVfog+h2rdNL8U/5HCDxIW8eUtdnyrgWmceANc7V+s5++e+DFFWUew== 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=1786465362; 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=olqfeoKAdZ3VkiUJ+KIYTzu0ha1ZB9Yd2OTja4KsOJA=; b=D6NJ7Yr2MDqBtZNb3JSQvbcg+CEraaGiyfn62St8T5G05+vabIIc2Im5HZG6OpOQnRSclE +yMzbLKKW+YaUbs5Fy1aMrUxJbGJ5Y7mDyRr9u/w9N9C1d++Lotn7SYlfBpJx/CFs2dVdI eGiSsx3UonIuXLGuZr9cHlzPLufZKxyzYmbpBpH0PP/THptC4UWZMmHniFBBdHfiSOTZ2K sfD8BixeXj5Sgmb5QOPt7y2E6nxzr4w46zSdQRfGW7qkCDqzTJQQUqrNpEwAXw8/GIWbcV TNz77plgZYCJlKlPc3ho9WIySW0dEdryCYmFHVUFahB6QvmYApFMC51rU/Wl9w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hKH36052tz12Vw for ; Tue, 11 Aug 2026 16:22:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3ab96 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 11 Aug 2026 16:22:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Andre Silva From: Mitchell Horne Subject: git: 66118c3f1011 - main - hwpmc: fix false runcount assertion in user callchain capture List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 66118c3f1011d7852bce8b659899179a83781897 Auto-Submitted: auto-generated Date: Tue, 11 Aug 2026 16:22:42 +0000 Message-Id: <6a7b4c52.3ab96.63e6f02c@gitrepo.freebsd.org> The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=66118c3f1011d7852bce8b659899179a83781897 commit 66118c3f1011d7852bce8b659899179a83781897 Author: Andre Silva AuthorDate: 2026-08-11 16:16:20 +0000 Commit: Mitchell Horne CommitDate: 2026-08-11 16:22:01 +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 --- 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 32bb00d671fe..e2d5a044e0b8 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -5016,9 +5016,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) { counter_u64_add(pmc_stats.pm_merges, 1); @@ -5044,6 +5041,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