From nobody Tue Oct 28 19:25:53 2025 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 4cx0hy022wz6DLq5; Tue, 28 Oct 2025 19:25:54 +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 4cx0hx6fg4z3WNN; Tue, 28 Oct 2025 19:25:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761679553; 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=K/L2TrvhNHLPBtDtAgzUDe6uos4JUVifAXY0+lJa5cA=; b=CaSoVZI8n6pVnh2IQ3SSMBvbu4AzhW/tkcsyMQg5OCUSq1Wao0Mvsed3qkohbeCO2BHSVF ey1C2TfcGPCgMu7jsiZkY5mTVXgNZ6VCpwJxLJinnSc/u+Bw8J43OH3qrGTMbdzqC7CcK4 YiPWcK5LaOsbQ5+GfVFTNVfvImK3Tw1LjyOxAvKh/0tieEyKelEe940LWjDkb+soC7GaLl z8pr9VUhHapbZ2rCtcnR7uU5e+JcheWETeZcfLE/HrV/RAHk9lBXF0KLOtiqxl8oiO9oHf z0iI+oV+lQRkH1NwNlBTfDEQC48Xe67Q3bboluRlQraHVu/R3eArbwMhTBXrQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761679553; 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=K/L2TrvhNHLPBtDtAgzUDe6uos4JUVifAXY0+lJa5cA=; b=n7DAOcDfqWQvbkO+pyNTb4y79vHluoADAXo6SO+r+3dOWGK2voEgfVqN+s1VNHe/OLrYme 0Xfvw7wUqghGahfglWluBhSzHGx63ZiAX0UasLDp6LjBMaR3dauY0Z/PD54YIxlO+zyBaq 6WGVJXcgGyzYug1jNH4TDIYd0aErsxrpoLoUChT4L9lEKjjh30IqeVhD6+NZLUNq613J4b NXMLhomMPY7rLmXfGkcTYOqHqZig05pALWP+nkiFxQfskqFdtRbGlT3ZdsuTF/y8UO6X88 yVUJLZU0qty6yO/Qx7HN0KU8g0/B7r0XqQ2MfI+GfcSBQBitAn4nrksqt7fiXA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761679553; a=rsa-sha256; cv=none; b=Gh9bMTh5X9MYGWTAYfbb96P5qhPhdWmgizf2NsGmjhTI4iPUNxKG82+6PnnQ6D9zzYy4My ww0y3fW9CbOq8P7nrH3mx4W7hyLwRWoqXYPwsrPTwX4Mjt6kIUIbW2SA91m2yEH+knbhrp stfXJEpMLp6smcmGWsVBmulHqvLFt8wgl2syUyVcNxZ9JkszN8H9bOCPL0nduA24wXbsDV 8K3UAbQbGyXbUDVowT0W/r+zFQhxTllLFmoUOLDL6fOJkBGSeocx5dSJ8/9AlYW5g2FCd6 xmWa0LIm5GvwEw8iWuTJqny+GbOEiIQrdoyqqGyzYOBfvsS8KayoKMbV/Obegg== 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 4cx0hx6GL0z13B1; Tue, 28 Oct 2025 19:25:53 +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 59SJPrW3050623; Tue, 28 Oct 2025 19:25:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59SJPriW050620; Tue, 28 Oct 2025 19:25:53 GMT (envelope-from git) Date: Tue, 28 Oct 2025 19:25:53 GMT Message-Id: <202510281925.59SJPriW050620@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jonathan T. Looney" Subject: git: 4b69237639bf - stable/14 - x86: support sending non-fatal MCA messages to syslog 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jtl X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4b69237639bf5472e01e21f6c4cdbe753375727d Auto-Submitted: auto-generated The branch stable/14 has been updated by jtl: URL: https://cgit.FreeBSD.org/src/commit/?id=4b69237639bf5472e01e21f6c4cdbe753375727d commit 4b69237639bf5472e01e21f6c4cdbe753375727d Author: Jonathan T. Looney AuthorDate: 2025-10-07 12:58:05 +0000 Commit: Jonathan T. Looney CommitDate: 2025-10-28 19:25:25 +0000 x86: support sending non-fatal MCA messages to syslog Currently, all MCA messages are logged to the console. However, this can have performance implications which can turn a storm of correctable errors into a disruptive event. Provide an option to direct non-fatal messages to syslog. Note that we will always log to the console for fatal errors. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D12278 (cherry picked from commit 55c28005f544282b984ae0e15dacd0c108d8ab12) --- sys/x86/x86/mca.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index a167854e8bbb..735efe307215 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -136,6 +137,11 @@ SYSCTL_INT(_hw_mca, OID_AUTO, fake_bank, CTLFLAG_RW, "Bank to use for artificial MCAs (testing purpose only)"); #endif +static bool mca_uselog = false; +SYSCTL_BOOL(_hw_mca, OID_AUTO, uselog, CTLFLAG_RWTUN, &mca_uselog, 0, + "Should the system send non-fatal machine check errors to the log " + "(instead of the console)?"); + static STAILQ_HEAD(, mca_internal) mca_freelist; static int mca_freecount; static STAILQ_HEAD(, mca_internal) mca_records; @@ -477,7 +483,7 @@ mca_mute(const struct mca_record *rec) /* Dump details about a single machine check. */ static void -mca_log(enum scan_mode mode, const struct mca_record *rec) +mca_log(enum scan_mode mode, const struct mca_record *rec, bool fatal) { int error, numskipped; uint16_t mca_error; @@ -711,7 +717,8 @@ mca_log(enum scan_mode mode, const struct mca_record *rec) event_type)); event_type = MCA_T_UNKNOWN; } - if (!uncor) { + numskipped = 0; + if (!fatal && !uncor) { /* * Update statistics and check the rate limit for * correctable errors. The rate limit is only applied @@ -732,17 +739,31 @@ mca_log(enum scan_mode mode, const struct mca_record *rec) numskipped = mca_log_skipped; mca_log_skipped = 0; mtx_unlock_spin(&mca_lock); + } + + error = sbuf_finish(&sb); + if (fatal || !mca_uselog) { if (numskipped > 0) printf("MCA: %d events skipped due to rate limit\n", numskipped); + if (error) + printf("MCA: error logging message (sbuf error %d)\n", + error); + else + sbuf_putbuf(&sb); + } else { + if (numskipped > 0) + log(LOG_ERR, + "MCA: %d events skipped due to rate limit\n", + numskipped); + if (error) + log(LOG_ERR, + "MCA: error logging message (sbuf error %d)\n", + error); + else + log(uncor ? LOG_CRIT : LOG_ERR, "%s", sbuf_data(&sb)); } - error = sbuf_finish(&sb); - if (error) - printf("MCA: error logging message (sbuf error %d)\n", error); - else - sbuf_putbuf(&sb); - done: sbuf_delete(&sb); if (using_shared_buf) @@ -907,7 +928,7 @@ mca_record_entry(enum scan_mode mode, const struct mca_record *record) if (rec == NULL) { mtx_unlock_spin(&mca_lock); printf("MCA: Unable to allocate space for an event.\n"); - mca_log(mode, record); + mca_log(mode, record, false); return; } STAILQ_REMOVE_HEAD(&mca_freelist, link); @@ -1064,7 +1085,7 @@ mca_scan(enum scan_mode mode, bool *recoverablep) if (*recoverablep) mca_record_entry(mode, &rec); else - mca_log(mode, &rec); + mca_log(mode, &rec, true); } #ifdef DEV_APIC @@ -1148,7 +1169,7 @@ mca_process_records(enum scan_mode mode) mtx_unlock_spin(&mca_lock); STAILQ_FOREACH(mca, &tmplist, link) - mca_log(mode, &mca->rec); + mca_log(mode, &mca->rec, false); mtx_lock_spin(&mca_lock); while ((mca = STAILQ_FIRST(&tmplist)) != NULL) {