Re: [PATCH v2] mm, oom: Fix race when selecting process to kill

From: Oleg Nesterov
Date: Fri Nov 08 2013 - 13:44:08 EST


Sorry.

I didn't have time to answer other emails, will try to do later.

And yes, yes, while_each_thread() should be fixed, still on my
TODO list... But just in case, whatever we do with while_each_thread()
we should also fix some users.

Until then,

On 11/08, Sameer Nanda wrote:
>
> @@ -412,13 +412,16 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
> static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
> DEFAULT_RATELIMIT_BURST);
>
> + read_lock(&tasklist_lock);
> +
> /*
> * 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 (p->flags & PF_EXITING || !pid_alive(p)) {

OK.

> - read_lock(&tasklist_lock);

But you should also move read_unlock_down(), at least after
find_lock_task_mm().

And of course, this doesn't fix other users in oom_kill.c.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/