History

watchdog: move watchdog sysctl interface to watchdog.c

The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic of proc sysctl. So, move the watchdog syscl interface to watchdog.c. Use register_sysctl() to register the sysctl interface to avoid merge conflicts when different features modify sysctl.c at the same time. [mcgrof@kernel.org: justify the move on the commit log]

Xiaoming Ni committed 4 years ago

Commit dd0693f1 parent bbe7a102 files · +101 −96Browse files

Showing the changes to kernel (2 of 2 files). Show all

Unified · Split

2 files
  1. kernel/sysctl.c +0 −96
  2. kernel/watchdog.c +101 −0
kernel/sysctl.c+0−96
@@ -103,16 +103,10 @@ · 102 unmodified lines
103#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE103#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
104#include <linux/stackleak.h>104#include <linux/stackleak.h>
105#endif105#endif
106#ifdef CONFIG_LOCKUP_DETECTOR
107#include <linux/nmi.h>
108#endif
109 106
110#if defined(CONFIG_SYSCTL)107#if defined(CONFIG_SYSCTL)
111 108
112/* Constants used for minimum and maximum */109/* Constants used for minimum and maximum */
113#ifdef CONFIG_LOCKUP_DETECTOR
114static int sixty = 60;
115#endif
116 110
117static unsigned long zero_ul;111static unsigned long zero_ul;
118static unsigned long one_ul = 1;112static unsigned long one_ul = 1;
@@ -2309,96 +2303,6 @@ static struct ctl_table kern_table[] = { · 2190 unmodified lines
2309 .mode = 0444,2303 .mode = 0444,
2310 .proc_handler = proc_dointvec,2304 .proc_handler = proc_dointvec,
2311 },2305 },
2312#if defined(CONFIG_LOCKUP_DETECTOR)
2313 {
2314 .procname = "watchdog",
2315 .data = &watchdog_user_enabled,
2316 .maxlen = sizeof(int),
2317 .mode = 0644,
2318 .proc_handler = proc_watchdog,
2319 .extra1 = SYSCTL_ZERO,
2320 .extra2 = SYSCTL_ONE,
2321 },
2322 {
2323 .procname = "watchdog_thresh",
2324 .data = &watchdog_thresh,
2325 .maxlen = sizeof(int),
2326 .mode = 0644,
2327 .proc_handler = proc_watchdog_thresh,
2328 .extra1 = SYSCTL_ZERO,
2329 .extra2 = &sixty,
2330 },
2331 {
2332 .procname = "nmi_watchdog",
2333 .data = &nmi_watchdog_user_enabled,
2334 .maxlen = sizeof(int),
2335 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2336 .proc_handler = proc_nmi_watchdog,
2337 .extra1 = SYSCTL_ZERO,
2338 .extra2 = SYSCTL_ONE,
2339 },
2340 {
2341 .procname = "watchdog_cpumask",
2342 .data = &watchdog_cpumask_bits,
2343 .maxlen = NR_CPUS,
2344 .mode = 0644,
2345 .proc_handler = proc_watchdog_cpumask,
2346 },
2347#ifdef CONFIG_SOFTLOCKUP_DETECTOR
2348 {
2349 .procname = "soft_watchdog",
2350 .data = &soft_watchdog_user_enabled,
2351 .maxlen = sizeof(int),
2352 .mode = 0644,
2353 .proc_handler = proc_soft_watchdog,
2354 .extra1 = SYSCTL_ZERO,
2355 .extra2 = SYSCTL_ONE,
2356 },
2357 {
2358 .procname = "softlockup_panic",
2359 .data = &softlockup_panic,
2360 .maxlen = sizeof(int),
2361 .mode = 0644,
2362 .proc_handler = proc_dointvec_minmax,
2363 .extra1 = SYSCTL_ZERO,
2364 .extra2 = SYSCTL_ONE,
2365 },
2366#ifdef CONFIG_SMP
2367 {
2368 .procname = "softlockup_all_cpu_backtrace",
2369 .data = &sysctl_softlockup_all_cpu_backtrace,
2370 .maxlen = sizeof(int),
2371 .mode = 0644,
2372 .proc_handler = proc_dointvec_minmax,
2373 .extra1 = SYSCTL_ZERO,
2374 .extra2 = SYSCTL_ONE,
2375 },
2376#endif /* CONFIG_SMP */
2377#endif
2378#ifdef CONFIG_HARDLOCKUP_DETECTOR
2379 {
2380 .procname = "hardlockup_panic",
2381 .data = &hardlockup_panic,
2382 .maxlen = sizeof(int),
2383 .mode = 0644,
2384 .proc_handler = proc_dointvec_minmax,
2385 .extra1 = SYSCTL_ZERO,
2386 .extra2 = SYSCTL_ONE,
2387 },
2388#ifdef CONFIG_SMP
2389 {
2390 .procname = "hardlockup_all_cpu_backtrace",
2391 .data = &sysctl_hardlockup_all_cpu_backtrace,
2392 .maxlen = sizeof(int),
2393 .mode = 0644,
2394 .proc_handler = proc_dointvec_minmax,
2395 .extra1 = SYSCTL_ZERO,
2396 .extra2 = SYSCTL_ONE,
2397 },
2398#endif /* CONFIG_SMP */
2399#endif
2400#endif
2401
2402#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)2306#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2403 {2307 {
2404 .procname = "unknown_nmi_panic",2308 .procname = "unknown_nmi_panic",
kernel/watchdog.c+101−0
@@ -740,6 +740,106 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write, · 739 unmodified lines
740 mutex_unlock(&watchdog_mutex);740 mutex_unlock(&watchdog_mutex);
741 return err;741 return err;
742}742}
743
744static const int sixty = 60;
745
746static struct ctl_table watchdog_sysctls[] = {
747 {
748 .procname = "watchdog",
749 .data = &watchdog_user_enabled,
750 .maxlen = sizeof(int),
751 .mode = 0644,
752 .proc_handler = proc_watchdog,
753 .extra1 = SYSCTL_ZERO,
754 .extra2 = SYSCTL_ONE,
755 },
756 {
757 .procname = "watchdog_thresh",
758 .data = &watchdog_thresh,
759 .maxlen = sizeof(int),
760 .mode = 0644,
761 .proc_handler = proc_watchdog_thresh,
762 .extra1 = SYSCTL_ZERO,
763 .extra2 = (void *)&sixty,
764 },
765 {
766 .procname = "nmi_watchdog",
767 .data = &nmi_watchdog_user_enabled,
768 .maxlen = sizeof(int),
769 .mode = NMI_WATCHDOG_SYSCTL_PERM,
770 .proc_handler = proc_nmi_watchdog,
771 .extra1 = SYSCTL_ZERO,
772 .extra2 = SYSCTL_ONE,
773 },
774 {
775 .procname = "watchdog_cpumask",
776 .data = &watchdog_cpumask_bits,
777 .maxlen = NR_CPUS,
778 .mode = 0644,
779 .proc_handler = proc_watchdog_cpumask,
780 },
781#ifdef CONFIG_SOFTLOCKUP_DETECTOR
782 {
783 .procname = "soft_watchdog",
784 .data = &soft_watchdog_user_enabled,
785 .maxlen = sizeof(int),
786 .mode = 0644,
787 .proc_handler = proc_soft_watchdog,
788 .extra1 = SYSCTL_ZERO,
789 .extra2 = SYSCTL_ONE,
790 },
791 {
792 .procname = "softlockup_panic",
793 .data = &softlockup_panic,
794 .maxlen = sizeof(int),
795 .mode = 0644,
796 .proc_handler = proc_dointvec_minmax,
797 .extra1 = SYSCTL_ZERO,
798 .extra2 = SYSCTL_ONE,
799 },
800#ifdef CONFIG_SMP
801 {
802 .procname = "softlockup_all_cpu_backtrace",
803 .data = &sysctl_softlockup_all_cpu_backtrace,
804 .maxlen = sizeof(int),
805 .mode = 0644,
806 .proc_handler = proc_dointvec_minmax,
807 .extra1 = SYSCTL_ZERO,
808 .extra2 = SYSCTL_ONE,
809 },
810#endif /* CONFIG_SMP */
811#endif
812#ifdef CONFIG_HARDLOCKUP_DETECTOR
813 {
814 .procname = "hardlockup_panic",
815 .data = &hardlockup_panic,
816 .maxlen = sizeof(int),
817 .mode = 0644,
818 .proc_handler = proc_dointvec_minmax,
819 .extra1 = SYSCTL_ZERO,
820 .extra2 = SYSCTL_ONE,
821 },
822#ifdef CONFIG_SMP
823 {
824 .procname = "hardlockup_all_cpu_backtrace",
825 .data = &sysctl_hardlockup_all_cpu_backtrace,
826 .maxlen = sizeof(int),
827 .mode = 0644,
828 .proc_handler = proc_dointvec_minmax,
829 .extra1 = SYSCTL_ZERO,
830 .extra2 = SYSCTL_ONE,
831 },
832#endif /* CONFIG_SMP */
833#endif
834 {}
835};
836
837static void __init watchdog_sysctl_init(void)
838{
839 register_sysctl_init("kernel", watchdog_sysctls);
840}
841#else
842#define watchdog_sysctl_init() do { } while (0)
743#endif /* CONFIG_SYSCTL */843#endif /* CONFIG_SYSCTL */
744 844
745void __init lockup_detector_init(void)845void __init lockup_detector_init(void)
@@ -753,4 +853,5 @@ void __init lockup_detector_init(void) · 7 unmodified lines
753 if (!watchdog_nmi_probe())853 if (!watchdog_nmi_probe())
754 nmi_watchdog_available = true;854 nmi_watchdog_available = true;
755 lockup_detector_setup();855 lockup_detector_setup();
856 watchdog_sysctl_init();
756}857}