From nobody Tue Apr 7 07:08:24 2026 Received: from sender-of-o57.zoho.eu (sender-of-o57.zoho.eu [136.143.169.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C64CA371D07 for ; Sun, 15 Mar 2026 19:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773604188; cv=pass; b=PKJAfKDJSsgsDUEMDjY3mQCC2AMEhUXdY/6PPHGEE5OQ/LWA3MySboJ7l/W8nGGkllNr26SSpX1M35YksXeP5yhJeVbKnjf+W7ljMStl4fZpDyRwHL1AS5rTXm7JlMrS1eqtQi+mVTyaqjWdMUmEflCnufvHwCKUsNE9osrjgLo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773604188; c=relaxed/simple; bh=BBOQZ7uYXbkZn1hEqJNOJPVr4KqZobF+zb1z7VaY5iw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JtLkI7ahgrOyj0/WuOjlX5i7M5PbKDYTLbjnH+sg9ejwTK/Q+IV6qF3H6UeJhVoXOFdu6xRiUltx/qVekUQqSZhx5bfJi6mIiOfVIyu3VA/w2wX1K0SP4rFkDtzJ/lGa9eI9t314rKpE8TTekNXKIk6EILWDTOTVZYX9BipK5dw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=dePFBTm5; arc=pass smtp.client-ip=136.143.169.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="dePFBTm5" ARC-Seal: i=1; a=rsa-sha256; t=1773604184; cv=none; d=zohomail.eu; s=zohoarc; b=eRK6eZGHbRgPcbNVmsPHgButjmUpLqnJrgyJO8vzcOkt2TSi4CHfXFZUjhycRGuNP8e3ZyoeKO3P4tYI4DM5X4pExTVccwRL5HXSyDoeOrFQY0BdWUGpWsaTWb+gjmJzeNEo+8rKeXoguX/Z5jto5WDUQis6FYTBIY3IG8fFZcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773604184; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=LXNHmlwozEZ7/B2Ox6/fvQuinccYbS0cEoN/uh1FurQ=; b=LceHM/ypp0lqnwZHa5yLhMSGFwoU8BDhbpvg3jj87Mwawd2f+h5cUVMstVfMEqD+7c+xz33N7f9y+jq5v4O/U1R2mPbCk7eHUeZbO30zC2OMnOEIbH6LjkddSxtzThxZbO3pBFX921dNvTDEXqXEEqG+ir8c70einsDFpK2x8rI= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773604184; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=LXNHmlwozEZ7/B2Ox6/fvQuinccYbS0cEoN/uh1FurQ=; b=dePFBTm5+lDHTHaw7GGxNBJdnreSnKmRhg/u5ds/2T8HkjOWm7RHNkkyGXeIH2dv oT7fLn2h2WLp6yab/RZhByfqVKQ0/LMiJiOKRvT7jzD/2jJTsgBbwwFRw0xBrqsOv3s 6Fw4Y2ctsakNkS6UenMsfXmFfxh8KEGXxs9x6hCw= Received: by mx.zoho.eu with SMTPS id 1773604182786489.602244670524; Sun, 15 Mar 2026 20:49:42 +0100 (CET) From: Josh Law To: Andrew Morton , Josh Law Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/3] lib/bug: add debugfs interface to list all BUG/WARN sites Date: Sun, 15 Mar 2026 19:49:39 +0000 Message-Id: <20260315194939.328612-4-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315194939.328612-1-objecting@objecting.org> References: <20260315194939.328612-1-objecting@objecting.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Currently there is no way to inspect the runtime state of WARN_ONCE sites. The existing clear_warn_once debugfs file lets operators reset them, but there is no counterpart to see which sites exist or which have already fired. On production systems this matters: when a WARN_ONCE fires during a transient event, the only evidence is a single dmesg line that may have already rotated out. Operators investigating later have no way to tell which WARN_ONCE sites have tripped without rebooting or reproducing the issue. Add /sys/kernel/debug/bug_sites which lists every registered BUG() and WARN() site in the kernel, including those from loaded modules. Each line shows the symbolized address, source location (file:line when CONFIG_DEBUG_BUGVERBOSE is enabled), type and state flags, and the module name if applicable. Example output: func+0x10/0x20 kernel/foo.c:123 warn,once,done bar+0x5/0x10 drivers/baz.c:456 warn [baz_mod] The "done" flag indicates that a WARN_ONCE site has fired at least once since boot (or since the last clear_warn_once), giving operators a reliable way to audit warning state on a running system without depending on log retention. Signed-off-by: Josh Law --- lib/bug.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/lib/bug.c b/lib/bug.c index 9d76703ff7d1..ddf4531d6661 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -48,6 +48,8 @@ #include #include #include +#include +#include =20 extern struct bug_entry __start___bug_table[], __stop___bug_table[]; =20 @@ -311,3 +313,68 @@ void generic_bug_clear_once(void) =20 clear_once_table(__start___bug_table, __stop___bug_table); } + +#ifdef CONFIG_DEBUG_FS +static void bug_show_entry(struct seq_file *m, const struct bug_entry *bug, + const char *modname) +{ + const char *file; + unsigned int line; + unsigned short flags =3D READ_ONCE(bug->flags); + + bug_get_file_line(bug, &file, &line); + + seq_printf(m, "%pS\t", (void *)bug_addr(bug)); + + if (file) + seq_printf(m, "%s:%u\t", file, line); + else + seq_puts(m, "-\t"); + + if (flags & BUGFLAG_WARNING) + seq_puts(m, "warn"); + else + seq_puts(m, "bug"); + if (flags & BUGFLAG_ONCE) + seq_puts(m, ",once"); + if (flags & BUGFLAG_DONE) + seq_puts(m, ",done"); + + if (modname) + seq_printf(m, "\t[%s]", modname); + + seq_putc(m, '\n'); +} + +static int bug_sites_show(struct seq_file *m, void *v) +{ + struct bug_entry *bug; + + for (bug =3D __start___bug_table; bug < __stop___bug_table; bug++) + bug_show_entry(m, bug, NULL); + +#ifdef CONFIG_MODULES + { + struct module *mod; + unsigned int i; + + rcu_read_lock(); + list_for_each_entry_rcu(mod, &module_bug_list, bug_list) + for (i =3D 0; i < mod->num_bugs; i++) + bug_show_entry(m, &mod->bug_table[i], + mod->name); + rcu_read_unlock(); + } +#endif + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(bug_sites); + +static int __init bug_debugfs_init(void) +{ + debugfs_create_file("bug_sites", 0444, NULL, NULL, &bug_sites_fops); + return 0; +} +device_initcall(bug_debugfs_init); +#endif /* CONFIG_DEBUG_FS */ --=20 2.34.1