From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752236AbdINKxG (ORCPT ); Thu, 14 Sep 2017 06:53:06 -0400 Received: from terminus.zytor.com ([65.50.211.136]:41465 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752221AbdINKxE (ORCPT ); Thu, 14 Sep 2017 06:53:04 -0400 Date: Thu, 14 Sep 2017 03:47:25 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: bp@alien8.de, mingo@kernel.org, dzickus@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, akpm@linux-foundation.org, peterz@infradead.org, bigeasy@linutronix.de, cmetcalf@mellanox.com, npiggin@gmail.com, torvalds@linux-foundation.org, tglx@linutronix.de, uobergfe@redhat.com Reply-To: uobergfe@redhat.com, tglx@linutronix.de, torvalds@linux-foundation.org, npiggin@gmail.com, cmetcalf@mellanox.com, bigeasy@linutronix.de, peterz@infradead.org, dzickus@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, akpm@linux-foundation.org, mingo@kernel.org, bp@alien8.de In-Reply-To: <20170912194147.706073616@linutronix.de> References: <20170912194147.706073616@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:core/urgent] watchdog/sysctl: Get rid of the #ifdeffery Git-Commit-ID: 51d4052b01ca555e0d1d5fe297b309beb6c64aa0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 51d4052b01ca555e0d1d5fe297b309beb6c64aa0 Gitweb: http://git.kernel.org/tip/51d4052b01ca555e0d1d5fe297b309beb6c64aa0 Author: Thomas Gleixner AuthorDate: Tue, 12 Sep 2017 21:37:14 +0200 Committer: Ingo Molnar CommitDate: Thu, 14 Sep 2017 11:41:07 +0200 watchdog/sysctl: Get rid of the #ifdeffery The sysctl of the nmi_watchdog file prevents writes by setting: min = max = 0 if none of the users is enabled. That involves ifdeffery and is competely non obvious. If none of the facilities is enabeld, then the file can simply be made read only. Move the ifdeffery into the header and use a constant for file permissions. Signed-off-by: Thomas Gleixner Reviewed-by: Don Zickus Cc: Andrew Morton Cc: Borislav Petkov Cc: Chris Metcalf Cc: Linus Torvalds Cc: Nicholas Piggin Cc: Peter Zijlstra Cc: Sebastian Siewior Cc: Ulrich Obergfell Link: http://lkml.kernel.org/r/20170912194147.706073616@linutronix.de Signed-off-by: Ingo Molnar --- include/linux/nmi.h | 6 ++++++ kernel/sysctl.c | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index cfebb3b..5774b443 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -81,6 +81,12 @@ extern unsigned int hardlockup_panic; static inline void hardlockup_detector_disable(void) {} #endif +#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) +# define NMI_WATCHDOG_SYSCTL_PERM 0644 +#else +# define NMI_WATCHDOG_SYSCTL_PERM 0444 +#endif + #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) extern void arch_touch_nmi_watchdog(void); extern void hardlockup_detector_perf_stop(void); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6648fbb..539cb4e 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -891,14 +891,10 @@ static struct ctl_table kern_table[] = { .procname = "nmi_watchdog", .data = &nmi_watchdog_enabled, .maxlen = sizeof (int), - .mode = 0644, + .mode = NMI_WATCHDOG_SYSCTL_PERM, .proc_handler = proc_nmi_watchdog, .extra1 = &zero, -#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) .extra2 = &one, -#else - .extra2 = &zero, -#endif }, { .procname = "watchdog_cpumask",