]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
watchdog: move nmi_watchdog sysctl into .rodata
authorJoel Granados <joel.granados@kernel.org>
Mon, 29 Sep 2025 12:43:54 +0000 (14:43 +0200)
committerJoel Granados <joel.granados@kernel.org>
Fri, 24 Oct 2025 13:35:11 +0000 (15:35 +0200)
Move nmi_watchdog into the watchdog_sysctls array to prevent it from
unnecessary modification. This move effectively moves it inside the
.rodata section.

Initially moved out into its own non-const array in commit 9ec272c586b0
("watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe
fails"), which made it writable only when watchdog_hardlockup_available
was true. Moving it back to watchdog_sysctl keeps this behavior as
writing to nmi_watchdog still fails when watchdog_hardlockup_available
is false.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
kernel/watchdog.c

index 5b62d10027836188dc1c3f4fe7e4ee4bd322b882..659f5844393cea129a70d3652d4028557f472c58 100644 (file)
@@ -1231,14 +1231,11 @@ static const struct ctl_table watchdog_sysctls[] = {
        },
 #endif /* CONFIG_SMP */
 #endif
-};
-
-static struct ctl_table watchdog_hardlockup_sysctl[] = {
        {
                .procname       = "nmi_watchdog",
                .data           = &watchdog_hardlockup_user_enabled,
                .maxlen         = sizeof(int),
-               .mode           = 0444,
+               .mode           = 0644,
                .proc_handler   = proc_nmi_watchdog,
                .extra1         = SYSCTL_ZERO,
                .extra2         = SYSCTL_ONE,
@@ -1248,10 +1245,6 @@ static struct ctl_table watchdog_hardlockup_sysctl[] = {
 static void __init watchdog_sysctl_init(void)
 {
        register_sysctl_init("kernel", watchdog_sysctls);
-
-       if (watchdog_hardlockup_available)
-               watchdog_hardlockup_sysctl[0].mode = 0644;
-       register_sysctl_init("kernel", watchdog_hardlockup_sysctl);
 }
 
 #else