aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/oom.h11
-rw-r--r--mm/memcontrol.c2
-rw-r--r--mm/oom_kill.c4
3 files changed, 14 insertions, 3 deletions
diff --git a/include/linux/oom.h b/include/linux/oom.h
index fbb0bead6..3ce57d6cf 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -87,6 +87,17 @@ static inline 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)
+{
+ /*
+ * 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.
+ */
+ return (task->flags & PF_EXITING) &&
+ !(task->signal->flags & SIGNAL_GROUP_COREDUMP);
+}
+
extern void dump_tasks(const struct mem_cgroup *memcg,
const nodemask_t *nodemask);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d6d5a7ea9..cb9dc56d3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1812,7 +1812,7 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
* 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) || current->flags & PF_EXITING) {
+ if (fatal_signal_pending(current) || task_will_free_mem(current)) {
set_thread_flag(TIF_MEMDIE);
return;
}
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1093dcd15..479d1723a 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -455,7 +455,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
* If the task is already exiting, don't alarm the sysadmin or kill
* its children or threads, just set TIF_MEMDIE so it can die quickly
*/
- if (p->flags & PF_EXITING) {
+ if (task_will_free_mem(p)) {
set_tsk_thread_flag(p, TIF_MEMDIE);
last_victim = jiffies;
put_task_struct(p);
@@ -688,7 +688,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
* 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) || current->flags & PF_EXITING) {
+ if (fatal_signal_pending(current) || task_will_free_mem(current)) {
set_thread_flag(TIF_MEMDIE);
last_victim = jiffies;
return;