提交 43fe219a 编写于 作者: S sujiaxun 提交者: Luis Chamberlain

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

[sfr@canb.auug.org.au: null-terminate the array]
  Link: https://lkml.kernel.org/r/20220216193202.28838626@canb.auug.org.au

Link: https://lkml.kernel.org/r/20220215093203.31032-1-sujiaxun@uniontech.comSigned-off-by: Nsujiaxun <sujiaxun@uniontech.com>
Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
Cc: Kees Cook <keescook@chromium.org>
Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
上级 06d17766
...@@ -123,8 +123,4 @@ extern void oom_killer_enable(void); ...@@ -123,8 +123,4 @@ extern void oom_killer_enable(void);
extern struct task_struct *find_lock_task_mm(struct task_struct *p); extern struct task_struct *find_lock_task_mm(struct task_struct *p);
/* sysctls */
extern int sysctl_oom_dump_tasks;
extern int sysctl_oom_kill_allocating_task;
extern int sysctl_panic_on_oom;
#endif /* _INCLUDE_LINUX_OOM_H */ #endif /* _INCLUDE_LINUX_OOM_H */
...@@ -2241,29 +2241,6 @@ static struct ctl_table vm_table[] = { ...@@ -2241,29 +2241,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO, .extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO, .extra2 = SYSCTL_TWO,
}, },
{
.procname = "panic_on_oom",
.data = &sysctl_panic_on_oom,
.maxlen = sizeof(sysctl_panic_on_oom),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
{
.procname = "oom_kill_allocating_task",
.data = &sysctl_oom_kill_allocating_task,
.maxlen = sizeof(sysctl_oom_kill_allocating_task),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "oom_dump_tasks",
.data = &sysctl_oom_dump_tasks,
.maxlen = sizeof(sysctl_oom_dump_tasks),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ {
.procname = "overcommit_ratio", .procname = "overcommit_ratio",
.data = &sysctl_overcommit_ratio, .data = &sysctl_overcommit_ratio,
......
...@@ -52,9 +52,38 @@ ...@@ -52,9 +52,38 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/oom.h> #include <trace/events/oom.h>
int sysctl_panic_on_oom; static int sysctl_panic_on_oom;
int sysctl_oom_kill_allocating_task; static int sysctl_oom_kill_allocating_task;
int sysctl_oom_dump_tasks = 1; static int sysctl_oom_dump_tasks = 1;
#ifdef CONFIG_SYSCTL
static struct ctl_table vm_oom_kill_table[] = {
{
.procname = "panic_on_oom",
.data = &sysctl_panic_on_oom,
.maxlen = sizeof(sysctl_panic_on_oom),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
{
.procname = "oom_kill_allocating_task",
.data = &sysctl_oom_kill_allocating_task,
.maxlen = sizeof(sysctl_oom_kill_allocating_task),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "oom_dump_tasks",
.data = &sysctl_oom_dump_tasks,
.maxlen = sizeof(sysctl_oom_dump_tasks),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{}
};
#endif
/* /*
* Serializes oom killer invocations (out_of_memory()) from all contexts to * Serializes oom killer invocations (out_of_memory()) from all contexts to
...@@ -677,6 +706,9 @@ static void wake_oom_reaper(struct task_struct *tsk) ...@@ -677,6 +706,9 @@ static void wake_oom_reaper(struct task_struct *tsk)
static int __init oom_init(void) static int __init oom_init(void)
{ {
oom_reaper_th = kthread_run(oom_reaper, NULL, "oom_reaper"); oom_reaper_th = kthread_run(oom_reaper, NULL, "oom_reaper");
#ifdef CONFIG_SYSCTL
register_sysctl_init("vm", vm_oom_kill_table);
#endif
return 0; return 0;
} }
subsys_initcall(oom_init) subsys_initcall(oom_init)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册