public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: move nmi_watchdog sysctl into .rodata
@ 2025-09-29 15:55 Joel Granados
  2025-10-06 15:06 ` Petr Mladek
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Granados @ 2025-09-29 15:55 UTC (permalink / raw)
  To: Petr Mladek, Daniel Xu; +Cc: linux-kernel, Joel Granados

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.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
This patch is a followup on the discussion/question I had in [1]. I
would prefer this to be const as it locks things in .rodata and prevents
inadvertent modifications [2].

[1] https://lore.kernel.org/all/588ec9ab-b38a-40b3-8db5-575a09e9a126@meta.com/
[2] https://lore.kernel.org/all/20250109-jag-ctl_table_const-v1-1-622aea7230cf@kernel.org/
---
 kernel/watchdog.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 80b56c002c7f123c49f65465fe7af9c74de4f46a..1e4e3eccb065a5ce95486f24fa07387e8218cd62 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -1213,14 +1213,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,
@@ -1230,10 +1227,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

---
base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
change-id: 20250929-jag-nmiwd_const-d7423ab25496

Best regards,
-- 
Joel Granados <joel.granados@kernel.org>



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-09 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 15:55 [PATCH] watchdog: move nmi_watchdog sysctl into .rodata Joel Granados
2025-10-06 15:06 ` Petr Mladek
2025-10-09 14:20   ` Joel Granados
2025-10-09 14:48     ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox