Skip to content

Commit 43fe219

Browse files
sujiaxunmcgrof
authored andcommitted
mm: move oom_kill sysctls to their 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. So move the oom_kill sysctls to their own file, mm/oom_kill.c [[email protected]: null-terminate the array] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: sujiaxun <[email protected]> Signed-off-by: Stephen Rothwell <[email protected]> Cc: Kees Cook <[email protected]> Cc: Iurii Zaikin <[email protected]> Cc: Michal Hocko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 06d1776 commit 43fe219

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

include/linux/oom.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,4 @@ extern void oom_killer_enable(void);
123123

124124
extern struct task_struct *find_lock_task_mm(struct task_struct *p);
125125

126-
/* sysctls */
127-
extern int sysctl_oom_dump_tasks;
128-
extern int sysctl_oom_kill_allocating_task;
129-
extern int sysctl_panic_on_oom;
130126
#endif /* _INCLUDE_LINUX_OOM_H */

kernel/sysctl.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,29 +2241,6 @@ static struct ctl_table vm_table[] = {
22412241
.extra1 = SYSCTL_ZERO,
22422242
.extra2 = SYSCTL_TWO,
22432243
},
2244-
{
2245-
.procname = "panic_on_oom",
2246-
.data = &sysctl_panic_on_oom,
2247-
.maxlen = sizeof(sysctl_panic_on_oom),
2248-
.mode = 0644,
2249-
.proc_handler = proc_dointvec_minmax,
2250-
.extra1 = SYSCTL_ZERO,
2251-
.extra2 = SYSCTL_TWO,
2252-
},
2253-
{
2254-
.procname = "oom_kill_allocating_task",
2255-
.data = &sysctl_oom_kill_allocating_task,
2256-
.maxlen = sizeof(sysctl_oom_kill_allocating_task),
2257-
.mode = 0644,
2258-
.proc_handler = proc_dointvec,
2259-
},
2260-
{
2261-
.procname = "oom_dump_tasks",
2262-
.data = &sysctl_oom_dump_tasks,
2263-
.maxlen = sizeof(sysctl_oom_dump_tasks),
2264-
.mode = 0644,
2265-
.proc_handler = proc_dointvec,
2266-
},
22672244
{
22682245
.procname = "overcommit_ratio",
22692246
.data = &sysctl_overcommit_ratio,

mm/oom_kill.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,38 @@
5252
#define CREATE_TRACE_POINTS
5353
#include <trace/events/oom.h>
5454

55-
int sysctl_panic_on_oom;
56-
int sysctl_oom_kill_allocating_task;
57-
int sysctl_oom_dump_tasks = 1;
55+
static int sysctl_panic_on_oom;
56+
static int sysctl_oom_kill_allocating_task;
57+
static int sysctl_oom_dump_tasks = 1;
58+
59+
#ifdef CONFIG_SYSCTL
60+
static struct ctl_table vm_oom_kill_table[] = {
61+
{
62+
.procname = "panic_on_oom",
63+
.data = &sysctl_panic_on_oom,
64+
.maxlen = sizeof(sysctl_panic_on_oom),
65+
.mode = 0644,
66+
.proc_handler = proc_dointvec_minmax,
67+
.extra1 = SYSCTL_ZERO,
68+
.extra2 = SYSCTL_TWO,
69+
},
70+
{
71+
.procname = "oom_kill_allocating_task",
72+
.data = &sysctl_oom_kill_allocating_task,
73+
.maxlen = sizeof(sysctl_oom_kill_allocating_task),
74+
.mode = 0644,
75+
.proc_handler = proc_dointvec,
76+
},
77+
{
78+
.procname = "oom_dump_tasks",
79+
.data = &sysctl_oom_dump_tasks,
80+
.maxlen = sizeof(sysctl_oom_dump_tasks),
81+
.mode = 0644,
82+
.proc_handler = proc_dointvec,
83+
},
84+
{}
85+
};
86+
#endif
5887

5988
/*
6089
* Serializes oom killer invocations (out_of_memory()) from all contexts to
@@ -677,6 +706,9 @@ static void wake_oom_reaper(struct task_struct *tsk)
677706
static int __init oom_init(void)
678707
{
679708
oom_reaper_th = kthread_run(oom_reaper, NULL, "oom_reaper");
709+
#ifdef CONFIG_SYSCTL
710+
register_sysctl_init("vm", vm_oom_kill_table);
711+
#endif
680712
return 0;
681713
}
682714
subsys_initcall(oom_init)

0 commit comments

Comments
 (0)