From nobody Sun Nov 22 15:42:28 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 4jXYH90yQpz724sj for ; Sun, 22 Nov 2026 15:42:29 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jXYH90MT1z51qp for ; Sun, 22 Nov 2026 15:42:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795362149; 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=6tOHbu+MLJB3pobdNBbrhIMAnCoi5qCxtrffc7La5MQ=; b=gKuVd4ucdVNypUv61sXClKW4qRprzHme9HOFh0if8dCUxWRcejwcsw1jIwUNp3cjf8OCU4 7g0ML90uiSSRvNWaQLxYvarbkmltj+G+wgtVsyGyOkR8zUgYvmd0fYsoTIq2H+/AoFLD27 ATr0XxCaF341EsEmQH3WbU3Tbx6XtlRqwKSL+WVbjyzId4vz4QxlwRyMj+ZPJGBC4GnaTL XUeS1FbDopHchFIXjsF4RjFZN3gaP/GiAH0jI7ORFxJARB5KfCbhaFmFDonh991bB7jkK0 RXUj00umM9+xtvpQ27IH5DbkqG/Z1HGU6AtpmcEq3tonF0mhgdnAfk1xl4o1+Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795362149; b=a6sS1Y4lbxDMUet1pbxMnvYEIC9iye7G43fdjkDqNc6E0mKzr9K5SWq3Ni2eXiPkKdGAx6 ZDfA6S2cHtZgT6spAIqk35ur14OUlkC59JK1MXZVv6Gr1kYS54p+AXli/66E8PUhTlNllU 4x39X49Gd2OWcbtor6Wo8y+WizKsC51uVDUX6Hay8UiC+ujejOtx14JbyoLHn00aZ/lTAB abLcfxvwjqOmMoO9ZgPU1TAmz0E/l8y9qXK4Vf1JsBJYjGaYjAwWK647Zbg6ELQzMUhKkp B67PMn79XeciuKB2bF9U82WjG/n4Ifa0yuNwusYS4vJrLYi1YN/gN77h1bSPNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795362149; 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=6tOHbu+MLJB3pobdNBbrhIMAnCoi5qCxtrffc7La5MQ=; b=ff0hinespHvNWR3LKxHgNLyDbqRXMiG/jNdEOMCw5kvx37DHFW++53A88SfUSUbhpWjrXC B+WrPclp8FA2a4rWEplqmIBY61ejnh4DbAC2BElhmWDkye39BZB1pWPlRqYz3f0m7JxOUL QlltQYiGqhPXw6ISB222sAIXJ/YWKewaC1s0hdEfNtGjHt43onQIpHgw5PjCcTmaRlOsA1 GCRlqSAWAkdxvzJ3U6slIgrbO4mGJPJgtkFSIf+hEIYMmfwWwGswpjk4Gf4s3fSMH7Ypiv VhwRMr/Vmsl3EfyM469T1hspYVCZlxsB729YyC4UT0iGhaBLftt/SVnKFNPOvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jXYH902NCz1PD0 for ; Sun, 22 Nov 2026 15:42:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id e03f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Nov 2026 15:42:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Nick Banks From: Andrew Gallatin Subject: git: 805405189b23 - main - hwpmc: claim stray PMI NMIs on Intel List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 805405189b23d702ce89674a55ca15c0d7c8142b Auto-Submitted: auto-generated Date: Sun, 22 Nov 2026 15:42:28 +0000 Message-Id: <6b030d64.e03f.16e28394@gitrepo.freebsd.org> The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=805405189b23d702ce89674a55ca15c0d7c8142b commit 805405189b23d702ce89674a55ca15c0d7c8142b Author: Nick Banks AuthorDate: 2026-11-22 15:35:49 +0000 Commit: Andrew Gallatin CommitDate: 2026-11-22 15:38:18 +0000 hwpmc: claim stray PMI NMIs on Intel core2_intr() claims an NMI only when IA_GLOBAL_STATUS shows an overflow. It re-enables the LAPIC PMC vector before acking the status bits, so a PMI raised while the handler runs can latch a second NMI that finds the status already clear. That NMI goes unclaimed and, with the default machdep.panic_on_nmi, panics the machine. hwpmc_amd.c already absorbs such NMIs with a per-CPU nmi_counter. Give core2_intr() one credit per serviced PMI and spend it on the next NMI on that CPU that finds no overflow. Reproduced on a Xeon D-1518 (Broadwell-DE) running system-wide CPU_CYCLES sampling: the unpatched kernel panicked with "NMI" after about 47k PMIs. With this change it ran 12.5 hours (485k PMIs), absorbed 6 empty NMIs, and did not panic. Sponsored by: Netflix Reviewed by: bnovkov, gallatin Differential Revision: https://reviews.freebsd.org/D61771 --- sys/dev/hwpmc/hwpmc_core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 83784b93718e..7c6217a59f4b 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -104,6 +105,9 @@ static int core_iap_wroffset; static u_int pmc_alloc_refs; static bool pmc_tsx_force_abort_set; +/* Stray-NMI credits, as in hwpmc_amd.c. */ +DPCPU_DEFINE_STATIC(uint32_t, core_nmi_counter); + static int core_pcpu_noop(struct pmc_mdep *md, int cpu) { @@ -1144,6 +1148,18 @@ core2_intr(struct trapframe *tf) wrmsr(core_iap_wroffset + IAP_PMC0 + n, v); } + /* + * A PMI raised while this handler runs can latch a second NMI + * whose status bits were already acked here. Claim one empty + * NMI per serviced PMI so it does not hit machdep.panic_on_nmi. + */ + if (found_interrupt) { + DPCPU_SET(core_nmi_counter, 1); + } else if (DPCPU_GET(core_nmi_counter) != 0) { + DPCPU_SET(core_nmi_counter, 0); + found_interrupt = 1; + } + if (found_interrupt) counter_u64_add(pmc_stats.pm_intr_processed, 1); else