oom_kill: change oom_kill.c to use for_each_thread()
authorOleg Nesterov <oleg@redhat.com>
Tue, 21 Jan 2014 23:49:58 +0000 (15:49 -0800)
committerJiri Slaby <jslaby@suse.cz>
Wed, 4 Jun 2014 14:25:55 +0000 (16:25 +0200)
commit7fdd16a11979a1cdb9157d144574010700497b69
tree5dff90d60d8367a919c2eb48b7c11552a909489f
parentebe219e45dcf94c1a34281167427cff4d742faef
oom_kill: change oom_kill.c to use for_each_thread()

commit 1da4db0cd5c8a31d4468ec906b413e75e604b465 upstream.

Change oom_kill.c to use for_each_thread() rather than the racy
while_each_thread() which can loop forever if we race with exit.

Note also that most users were buggy even if while_each_thread() was
fine, the task can exit even _before_ rcu_read_lock().

Fortunately the new for_each_thread() only requires the stable
task_struct, so this change fixes both problems.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Sergey Dyasly <dserrg@gmail.com>
Tested-by: Sergey Dyasly <dserrg@gmail.com>
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mandeep Singh Baines <msb@chromium.org>
Cc: "Ma, Xindong" <xindong.ma@intel.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Cc: "Tu, Xiaobing" <xiaobing.tu@intel.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
mm/oom_kill.c