The current PF_EXITING check in select_bad_process() is very limited, it only works if the task is single-threaded. Add the new helper which tries to handle the mt case. It is not exactly clear what should we actually check in this case. This patch checks PF_EXITING, but perhaps we can take signal_group_exit() into account. In this case select_bad_process() could detect the exiting process even before every thread calls exit(). Note: "if (p != current)" check is obviously wrong in mt case too. Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx> --- mm/oom_kill.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- 38/mm/oom_kill.c~detect_exiting 2011-03-10 16:08:51.000000000 +0100 +++ 38/mm/oom_kill.c 2011-03-10 17:21:40.000000000 +0100 @@ -282,6 +282,21 @@ static enum oom_constraint constrained_a } #endif +static bool mm_is_exiting(struct task_struct *p) +{ + struct task_struct *t; + bool has_mm = false; + + do { + if (!(p->flags & PF_EXITING)) + return false; + if (t->mm) + has_mm = true; + } while_each_thread(p, t); + + return has_mm; +} + /* * Simple selection loop. We chose the process with the highest * number of 'points'. We expect the caller will lock the tasklist. @@ -324,7 +339,7 @@ static struct task_struct *select_bad_pr * the process of exiting and releasing its resources. * Otherwise we could get an easy OOM deadlock. */ - if (thread_group_empty(p) && (p->flags & PF_EXITING) && p->mm) { + if (mm_is_exiting(p)) { if (p != current) return ERR_PTR(-1UL); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxxx For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>