mm, oom: fortify task_will_free_mem()
Subsystems (3)
[email protected]
maintainerPATCH 7/101 mm, oom: fortify task_will_free_mem()
From: Michal Hocko <[email protected]>
Subject: mm, oom: fortify task_will_free_mem()
task_will_free_mem is rather weak. It doesn't really tell whether the task has chance to drop its mm. 98748bd72200 ("oom: consider multi-threaded tasks in task_will_free_mem") made a first step into making it more robust for multi-threaded applications so now we know that the whole process is going down and probably drop the mm.
This patch builds on top for more complex scenarios where mm is shared between different processes - CLONE_VM without CLONE_SIGHAND, or in kernel use_mm().
Make sure that all processes sharing the mm are killed or exiting. This will allow us to replace try_oom_reaper by wake_oom_reaper because task_will_free_mem implies the task is reapable now. Therefore all paths which bypass the oom killer are now reapable and so they shouldn't lock up the oom killer.
---
include/linux/oom.h | 26 -------- mm/memcontrol.c | 4 - mm/oom_kill.c | 133 +++++++++++++++++++++++++----------------- 3 files changed, 85 insertions(+), 78 deletions(-)
include/linux/oom.h renamed from include/linux/oom.h~mm-oom-fortify-task_will_free_mem +3 -23
@@ -73,9 +73,9 @@ static inline bool oom_task_origin(constextern void mark_oom_victim (struct task_struct *tsk);#ifdef CONFIG_MMU -extern void try_oom_reaper (struct task_struct *tsk); +extern void wake_oom_reaper (struct task_struct *tsk);#else -static inline void try_oom_reaper (struct task_struct *tsk) +static inline void wake_oom_reaper (struct task_struct *tsk) { }#endif
@@ -107,27 +107,7 @@ extern void oom_killer_enable(void);extern struct task_struct *find_lock_task_mm (struct task_struct *p); -static inline bool task_will_free_mem (struct task_struct *task) -{ -struct signal_struct *sig = task->signal; - -/* -* A coredumping process may sleep for an extended period in exit_mm(), -* so the oom killer cannot assume that the process will promptly exit -* and release memory. -*/ -if (sig->flags &SIGNAL_GROUP_COREDUMP ) -return false; - -if (!(task->flags &PF_EXITING )) -return false; - -/* Make sure that the whole thread group is going down */ -if (!thread_group_empty (task) && !(sig->flags &SIGNAL_GROUP_EXIT )) -return false; - -return true; -} +bool task_will_free_mem (struct task_struct *task);/* sysctls */ extern int sysctl_oom_dump_tasks;
mm/memcontrol.c renamed from mm/memcontrol.c~mm-oom-fortify-task_will_free_mem +2 -2
@@ -1276,9 +1276,9 @@ static bool mem_cgroup_out_of_memory(str* select it. The goal is to allow it to allocate so that it may * quickly exit and free its memory. */ -if (fatal_signal_pending (current) ||task_will_free_mem (current)) { +if (task_will_free_mem (current)) {mark_oom_victim (current); -try_oom_reaper (current); +wake_oom_reaper (current); goto unlock; }
mm/oom_kill.c renamed from mm/oom_kill.c~mm-oom-fortify-task_will_free_mem +80 -53
174 lines not on this page · raw message
_