linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Sameer Nanda <snanda@chromium.org>
Cc: akpm@linux-foundation.org, mhocko@suse.cz, rientjes@google.com,
	hannes@cmpxchg.org, rusty@rustcorp.com.au, semenzato@google.com,
	murzin.v@gmail.com, dserrg@gmail.com, msb@chromium.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] mm, oom: Fix race when selecting process to kill
Date: Wed, 13 Nov 2013 18:29:18 +0100	[thread overview]
Message-ID: <20131113172918.GA20145@redhat.com> (raw)
In-Reply-To: <1384363093-8025-1-git-send-email-snanda@chromium.org>

On 11/13, Sameer Nanda wrote:
>
> The selection of the process to be killed happens in two spots:
> first in select_bad_process and then a further refinement by
> looking for child processes in oom_kill_process. Since this is
> a two step process, it is possible that the process selected by
> select_bad_process may get a SIGKILL just before oom_kill_process
> executes. If this were to happen, __unhash_process deletes this
> process from the thread_group list. This results in oom_kill_process
> getting stuck in an infinite loop when traversing the thread_group
> list of the selected process.
>
> Fix this race by adding a pid_alive check for the selected process
> with tasklist_lock held in oom_kill_process.

I am fine with this patch as well, but honestly I'd prefer the previous
v5. I won't argue though.

> +/*
> + * Careful: while_each_thread is not RCU safe. Callers should hold
> + * read_lock(tasklist_lock) across while_each_thread loops.
> + */

(tasklist_lock or siglock, in fact but this doesn't matter).

This is not that simple, even tasklist_lock can't help if the task is
already dead.

Oh. Yes, sorry. I promised to send the patches "soon" many times, but
still didn't find the time.

Perhaps I should try to start with the "make this all less buggy" changes,
the "complete" fix needs to change the callers as well.

Oleg.


  reply	other threads:[~2013-11-13 17:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 23:26 [PATCH] mm, oom: Fix race when selecting process to kill Sameer Nanda
2013-11-06  1:18 ` David Rientjes
2013-11-06  1:25   ` Luigi Semenzato
2013-11-06  1:27     ` David Rientjes
2013-11-06  3:00       ` Vladimir Murzin
     [not found]       ` <CANMivWZrefY1bbgpJgABqcUwKfqOR9HQtGNY6cWdutcMASeo2A@mail.gmail.com>
2013-11-06  4:45         ` Luigi Semenzato
2013-11-06  7:17           ` Luigi Semenzato
2013-11-06 16:58             ` Sameer Nanda
2013-11-07  0:35               ` David Rientjes
2013-11-07 19:34                 ` Sameer Nanda
2013-11-08 18:07                 ` [PATCH v2] " Sameer Nanda
2013-11-08 18:45                   ` Oleg Nesterov
2013-11-08 19:49                     ` [PATCH v3] " Sameer Nanda
2013-11-09 15:16                       ` Oleg Nesterov
2013-11-12  0:21                         ` [PATCH v4] " Sameer Nanda
2013-11-12 15:13                           ` Michal Hocko
2013-11-12 20:01                           ` Oleg Nesterov
2013-11-12 20:08                             ` Sameer Nanda
2013-11-12 20:23                               ` [PATCH v5] " Sameer Nanda
2013-11-13  2:33                                 ` David Rientjes
2013-11-13 16:46                                   ` Sameer Nanda
2013-11-13 17:18                                     ` [PATCH v6] " Sameer Nanda
2013-11-13 17:29                                       ` Oleg Nesterov [this message]
     [not found]                                       ` <CAMw+i9hi9pBPkfWHo3mh0=PATQFzbNOCSPaLkw+zqUvwK2wbxA@mail.gmail.com>
2013-11-14 17:03                                         ` Sameer Nanda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131113172918.GA20145@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dserrg@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=msb@chromium.org \
    --cc=murzin.v@gmail.com \
    --cc=rientjes@google.com \
    --cc=rusty@rustcorp.com.au \
    --cc=semenzato@google.com \
    --cc=snanda@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).