Skip to content

Commit 9df9186

Browse files
imtangmengmcgrof
authored andcommitted
kernel/panic: move panic sysctls to its own file
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. All filesystem syctls now get reviewed by fs folks. This commit follows the commit of fs, move the oops_all_cpu_backtrace sysctl to its own file, kernel/panic.c. Signed-off-by: tangmeng <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent f79c9b8 commit 9df9186

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

include/linux/panic.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ extern void oops_enter(void);
1515
extern void oops_exit(void);
1616
extern bool oops_may_print(void);
1717

18-
#ifdef CONFIG_SMP
19-
extern unsigned int sysctl_oops_all_cpu_backtrace;
20-
#else
21-
#define sysctl_oops_all_cpu_backtrace 0
22-
#endif /* CONFIG_SMP */
23-
2418
extern int panic_timeout;
2519
extern unsigned long panic_print;
2620
extern int panic_on_oops;

kernel/panic.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
* Should we dump all CPUs backtraces in an oops event?
4444
* Defaults to 0, can be changed via sysctl.
4545
*/
46-
unsigned int __read_mostly sysctl_oops_all_cpu_backtrace;
46+
static unsigned int __read_mostly sysctl_oops_all_cpu_backtrace;
47+
#else
48+
#define sysctl_oops_all_cpu_backtrace 0
4749
#endif /* CONFIG_SMP */
4850

4951
int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE;
@@ -73,6 +75,28 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
7375

7476
EXPORT_SYMBOL(panic_notifier_list);
7577

78+
#if defined(CONFIG_SMP) && defined(CONFIG_SYSCTL)
79+
static struct ctl_table kern_panic_table[] = {
80+
{
81+
.procname = "oops_all_cpu_backtrace",
82+
.data = &sysctl_oops_all_cpu_backtrace,
83+
.maxlen = sizeof(int),
84+
.mode = 0644,
85+
.proc_handler = proc_dointvec_minmax,
86+
.extra1 = SYSCTL_ZERO,
87+
.extra2 = SYSCTL_ONE,
88+
},
89+
{ }
90+
};
91+
92+
static __init int kernel_panic_sysctls_init(void)
93+
{
94+
register_sysctl_init("kernel", kern_panic_table);
95+
return 0;
96+
}
97+
late_initcall(kernel_panic_sysctls_init);
98+
#endif
99+
76100
static long no_blink(int state)
77101
{
78102
return 0;

kernel/sysctl.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,17 +1922,6 @@ static struct ctl_table kern_table[] = {
19221922
.proc_handler = proc_dointvec,
19231923
},
19241924
#endif
1925-
#ifdef CONFIG_SMP
1926-
{
1927-
.procname = "oops_all_cpu_backtrace",
1928-
.data = &sysctl_oops_all_cpu_backtrace,
1929-
.maxlen = sizeof(int),
1930-
.mode = 0644,
1931-
.proc_handler = proc_dointvec_minmax,
1932-
.extra1 = SYSCTL_ZERO,
1933-
.extra2 = SYSCTL_ONE,
1934-
},
1935-
#endif /* CONFIG_SMP */
19361925
{
19371926
.procname = "pid_max",
19381927
.data = &pid_max,

0 commit comments

Comments
 (0)