From nobody Fri Nov 12 14:44:12 2021 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 5C16818474C7; Fri, 12 Nov 2021 14:44:13 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HrLvK0yXkz4TpL; Fri, 12 Nov 2021 14:44:13 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CA84621153; Fri, 12 Nov 2021 14:44:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1ACEiCw4093944; Fri, 12 Nov 2021 14:44:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ACEiCge093943; Fri, 12 Nov 2021 14:44:12 GMT (envelope-from git) Date: Fri, 12 Nov 2021 14:44:12 GMT Message-Id: <202111121444.1ACEiCge093943@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 0e9e3016b9db - stable/12 - LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's. 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 0e9e3016b9db4572f78ebb7cf475e8fae84e37df Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=0e9e3016b9db4572f78ebb7cf475e8fae84e37df commit 0e9e3016b9db4572f78ebb7cf475e8fae84e37df Author: Hans Petter Selasky AuthorDate: 2021-11-12 14:43:52 +0000 Commit: Hans Petter Selasky CommitDate: 2021-11-12 14:43:52 +0000 LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's. The purpose of this change is to reduce the amount of dmesg(8) noise when VT switching after a panic. Submitted by: Greg V Differential Revision: https://reviews.freebsd.org/D30174 Sponsored by: NVIDIA Networking (cherry picked from commit 2390a1441effaba0e3d0f2f447f448aaf20428f1) --- sys/compat/linuxkpi/common/include/linux/kernel.h | 25 +++++++++++++---------- sys/compat/linuxkpi/common/src/linux_compat.c | 5 +++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 36d89cf83557..9e96c9935e45 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -105,28 +105,31 @@ extern const volatile int lkpi_build_bug_on_zero; } \ } while (0) +extern int linuxkpi_warn_dump_stack; #define WARN_ON(cond) ({ \ - bool __ret = (cond); \ - if (__ret) { \ + bool __ret = (cond); \ + if (__ret) { \ printf("WARNING %s failed at %s:%d\n", \ __stringify(cond), __FILE__, __LINE__); \ - linux_dump_stack(); \ - } \ - unlikely(__ret); \ + if (linuxkpi_warn_dump_stack) \ + linux_dump_stack(); \ + } \ + unlikely(__ret); \ }) #define WARN_ON_SMP(cond) WARN_ON(cond) #define WARN_ON_ONCE(cond) ({ \ - static bool __warn_on_once; \ - bool __ret = (cond); \ - if (__ret && !__warn_on_once) { \ + static bool __warn_on_once; \ + bool __ret = (cond); \ + if (__ret && !__warn_on_once) { \ __warn_on_once = 1; \ printf("WARNING %s failed at %s:%d\n", \ __stringify(cond), __FILE__, __LINE__); \ - linux_dump_stack(); \ - } \ - unlikely(__ret); \ + if (linuxkpi_warn_dump_stack) \ + linux_dump_stack(); \ + } \ + unlikely(__ret); \ }) #define oops_in_progress SCHEDULER_STOPPED() diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index bb649e42ab8c..e3ccda6e8f23 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -98,6 +98,11 @@ int linuxkpi_debug; SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug, CTLFLAG_RWTUN, &linuxkpi_debug, 0, "Set to enable pr_debug() prints. Clear to disable."); +int linuxkpi_warn_dump_stack = 0; +SYSCTL_INT(_compat_linuxkpi, OID_AUTO, warn_dump_stack, CTLFLAG_RWTUN, + &linuxkpi_warn_dump_stack, 0, + "Set to enable stack traces from WARN_ON(). Clear to disable."); + static struct timeval lkpi_net_lastlog; static int lkpi_net_curpps; static int lkpi_net_maxpps = 99;