aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-10-07 19:59:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-07 21:46:28 -0400
commit1b51e65eab64fac72cab009691e8ca9915624876 (patch)
tree9b237501f047a41f879779a57ee308d54194d7e8
parent3f70dc38cec2ad6e5355f80c4c7a15a3f7e97a19 (diff)
oom, oom_reaper: allow to reap mm shared by the kthreads
oom reaper was skipped for an mm which is shared with the kernel thread (aka use_mm()). The primary concern was that such a kthread might want to read from the userspace memory and see zero page as a result of the oom reaper action. This is no longer a problem after "mm: make sure that kthreads will not refault oom reaped memory" because any attempt to fault in when the MMF_UNSTABLE is set will result in SIGBUS and so the target user should see an error. This means that we can finally allow oom reaper also to tasks which share their mm with kthreads. Link: http://lkml.kernel.org/r/1472119394-11342-10-git-send-email-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Oleg Nesterov <oleg@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Vladimir Davydov <vdavydov@parallels.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/oom_kill.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5a3ba96c8338..10f686969fc4 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -902,13 +902,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
902 continue; 902 continue;
903 if (same_thread_group(p, victim)) 903 if (same_thread_group(p, victim))
904 continue; 904 continue;
905 if (unlikely(p->flags & PF_KTHREAD) || is_global_init(p)) { 905 if (is_global_init(p)) {
906 /*
907 * We cannot use oom_reaper for the mm shared by this
908 * process because it wouldn't get killed and so the
909 * memory might be still used. Hide the mm from the oom
910 * killer to guarantee OOM forward progress.
911 */
912 can_oom_reap = false; 906 can_oom_reap = false;
913 set_bit(MMF_OOM_SKIP, &mm->flags); 907 set_bit(MMF_OOM_SKIP, &mm->flags);
914 pr_info("oom killer %d (%s) has mm pinned by %d (%s)\n", 908 pr_info("oom killer %d (%s) has mm pinned by %d (%s)\n",
@@ -916,6 +910,12 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
916 task_pid_nr(p), p->comm); 910 task_pid_nr(p), p->comm);
917 continue; 911 continue;
918 } 912 }
913 /*
914 * No use_mm() user needs to read from the userspace so we are
915 * ok to reap it.
916 */
917 if (unlikely(p->flags & PF_KTHREAD))
918 continue;
919 do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true); 919 do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
920 } 920 }
921 rcu_read_unlock(); 921 rcu_read_unlock();