In the event debugfs is not mounted, or if built with the .config
setting DEBUG_FS_ALLOW_NONE chosen, this gives the sysadmin access
to reset the WARN_ONCE() state on a periodic basis.

Link: 
https://lore.kernel.org/r/[email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
 .../admin-guide/kernel-parameters.txt         |  8 +++++++
 kernel/panic.c                                | 21 +++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index fea15cd49fbc..de0dd2139414 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5351,6 +5351,14 @@
        vt.underline=   [VT] Default color for underlined text; 0-15.
                        Default: 3 = cyan.
 
+       clear_warn_once=
+                       [KNL]
+                       Set the WARN_ONCE reset period in minutes.  Normally
+                       a WARN_ONCE() will only ever emit a message once per
+                       boot, but for example, setting this to 60 would
+                       effectively rate-limit WARN_ONCE to once per hour.
+                       Default: 0 = never.
+
        watchdog timers [HW,WDT] For information on watchdog timers,
                        see Documentation/watchdog/watchdog-parameters.rst
                        or other driver-specific files in the
diff --git a/kernel/panic.c b/kernel/panic.c
index e3a462e39062..f4f3633f4f69 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -697,10 +697,31 @@ static __init int register_warn_debugfs(void)
        /* Don't care about failure */
        debugfs_create_file_unsafe("clear_warn_once", 0600, NULL,
                                   &clear_warn_once, &clear_warn_once_fops);
+
+       /* if a bootarg was used, set the initial timer */
+       if (clear_warn_once)
+               warn_once_set(NULL, clear_warn_once);
+
        return 0;
 }
 
 device_initcall(register_warn_debugfs);
+
+static int __init warn_once_setup(char *s)
+{
+       int r;
+
+       if (!s)
+               return -EINVAL;
+
+       r = kstrtoull(s, 0, &clear_warn_once);
+       if (r)
+               return r;
+
+       return 1;
+}
+__setup("clear_warn_once=", warn_once_setup);
+
 #endif
 
 #ifdef CONFIG_STACKPROTECTOR
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9278): 
https://lists.yoctoproject.org/g/linux-yocto/message/9278
Mute This Topic: https://lists.yoctoproject.org/mt/79006239/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to