Commit af8e15cc authored by Michal Hocko's avatar Michal Hocko Committed by Linus Torvalds

oom, oom_reaper: do not enqueue task if it is on the oom_reaper_list head

Commit bb29902a ("oom, oom_reaper: protect oom_reaper_list using
simpler way") has simplified the check for tasks already enqueued for
the oom reaper by checking tsk->oom_reaper_list != NULL.  This check is
not sufficient because the tsk might be the head of the queue without
any other tasks queued and then we would simply lockup looping on the
same task.  Fix the condition by checking for the head as well.

Fixes: bb29902a ("oom, oom_reaper: protect oom_reaper_list using simpler way")
Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
Acked-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bbe3de25
...@@ -547,7 +547,11 @@ static int oom_reaper(void *unused) ...@@ -547,7 +547,11 @@ static int oom_reaper(void *unused)
static void wake_oom_reaper(struct task_struct *tsk) static void wake_oom_reaper(struct task_struct *tsk)
{ {
if (!oom_reaper_th || tsk->oom_reaper_list) if (!oom_reaper_th)
return;
/* tsk is already queued? */
if (tsk == oom_reaper_list || tsk->oom_reaper_list)
return; return;
get_task_struct(tsk); get_task_struct(tsk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment