All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: + freezer-check-oom-kill-while-being-frozen.patch added to -mm tree
@ 2014-10-16 20:39 Oleg Nesterov
  2014-10-16 20:53 ` Cong Wang
  2014-10-17  6:59 ` Michal Hocko
  0 siblings, 2 replies; 19+ messages in thread
From: Oleg Nesterov @ 2014-10-16 20:39 UTC (permalink / raw)
  To: Cong Wang, Michal Hocko, David Rientjes, Rafael J. Wysocki,
	Tejun Heo, Andrew Morton
  Cc: linux-kernel

> Fix the issue by checking for TIF_MEMDIE thread flag and get away from the
> fridge if it is set.  oom_scan_process_thread doesn't have to check for
> the frozen task anymore because do_send_sig_info will wake up the thread
> and TIF_MEMDIE is already set by that time.

I must have missed something... but __refrigerator() sleeps in
TASK_UNINTERRUPTIBLE and do_send_sig_info() won't wake it up?

Oleg.


^ permalink raw reply	[flat|nested] 19+ messages in thread
* + freezer-check-oom-kill-while-being-frozen.patch added to -mm tree
@ 2014-10-14 22:07 akpm
  0 siblings, 0 replies; 19+ messages in thread
From: akpm @ 2014-10-14 22:07 UTC (permalink / raw)
  To: xiyou.wangcong, mhocko, rientjes, rjw, stable, tj, mm-commits


The patch titled
     Subject: freezer: check OOM kill while being frozen
has been added to the -mm tree.  Its filename is
     freezer-check-oom-kill-while-being-frozen.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/freezer-check-oom-kill-while-being-frozen.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/freezer-check-oom-kill-while-being-frozen.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Cong Wang <xiyou.wangcong@gmail.com>
Subject: freezer: check OOM kill while being frozen

Since f660daac474c6f ("oom: thaw threads if oom killed thread is frozen
before deferring") OOM killer relies on being able to thaw a frozen task
to handle OOM situation but a3201227f803 (freezer: make freezing() test
freeze conditions in effect instead of TIF_FREEZE) has reorganized the
code and stopped clearing freeze flag in __thaw_task.  This means that the
target task only wakes up and goes into the fridge again because the
freezing condition hasn't changed for it.  This reintroduces the bug fixed
by f660daac474c6f.

Fix the issue by checking for TIF_MEMDIE thread flag and get away from the
fridge if it is set.  oom_scan_process_thread doesn't have to check for
the frozen task anymore because do_send_sig_info will wake up the thread
and TIF_MEMDIE is already set by that time.

Fixes: a3201227f803 (freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE)
[mhocko@suse.cz: rewrote the changelog]
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Tejun Heo <tj@kernel.org>
Cc: <stable@vger.kernel.org>	[3.3+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/freezer.c |   20 +++++++++++++++++---
 mm/oom_kill.c    |    2 --
 2 files changed, 17 insertions(+), 5 deletions(-)

diff -puN kernel/freezer.c~freezer-check-oom-kill-while-being-frozen kernel/freezer.c
--- a/kernel/freezer.c~freezer-check-oom-kill-while-being-frozen
+++ a/kernel/freezer.c
@@ -45,13 +45,28 @@ bool freezing_slow_path(struct task_stru
 	if (pm_nosig_freezing || cgroup_freezing(p))
 		return true;
 
-	if (pm_freezing && !(p->flags & PF_KTHREAD))
+	if (!(p->flags & PF_KTHREAD))
 		return true;
 
 	return false;
 }
 EXPORT_SYMBOL(freezing_slow_path);
 
+static bool should_thaw_current(bool check_kthr_stop)
+{
+	if (!freezing(current))
+		return true;
+
+	if (check_kthr_stop && kthread_should_stop())
+		return true;
+
+	/* It might not be safe to check TIF_MEMDIE for pm freeze. */
+	if (cgroup_freezing(current) && test_thread_flag(TIF_MEMDIE))
+		return true;
+
+	return false;
+}
+
 /* Refrigerator is place where frozen processes are stored :-). */
 bool __refrigerator(bool check_kthr_stop)
 {
@@ -67,8 +82,7 @@ bool __refrigerator(bool check_kthr_stop
 
 		spin_lock_irq(&freezer_lock);
 		current->flags |= PF_FROZEN;
-		if (!freezing(current) ||
-		    (check_kthr_stop && kthread_should_stop()))
+		if (should_thaw_current(check_kthr_stop))
 			current->flags &= ~PF_FROZEN;
 		spin_unlock_irq(&freezer_lock);
 
diff -puN mm/oom_kill.c~freezer-check-oom-kill-while-being-frozen mm/oom_kill.c
--- a/mm/oom_kill.c~freezer-check-oom-kill-while-being-frozen
+++ a/mm/oom_kill.c
@@ -266,8 +266,6 @@ enum oom_scan_t oom_scan_process_thread(
 	 * Don't allow any other task to have access to the reserves.
 	 */
 	if (test_tsk_thread_flag(task, TIF_MEMDIE)) {
-		if (unlikely(frozen(task)))
-			__thaw_task(task);
 		if (!force_kill)
 			return OOM_SCAN_ABORT;
 	}
_

Patches currently in -mm which might be from xiyou.wangcong@gmail.com are

origin.patch
freezer-check-oom-kill-while-being-frozen.patch
freezer-remove-obsolete-comments-in-__thaw_task.patch
oom-pm-oom-killed-task-cannot-escape-pm-suspend.patch
linux-next.patch


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-10-20 17:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 20:39 + freezer-check-oom-kill-while-being-frozen.patch added to -mm tree Oleg Nesterov
2014-10-16 20:53 ` Cong Wang
2014-10-16 21:11   ` Oleg Nesterov
2014-10-16 21:19     ` Cong Wang
2014-10-16 21:35       ` Oleg Nesterov
2014-10-16 21:52         ` Cong Wang
2014-10-16 22:22           ` Oleg Nesterov
2014-10-17  2:33             ` Cong Wang
2014-10-17  7:46               ` [PATCH -v2] freezer: check OOM kill while being frozen Michal Hocko
2014-10-17 16:10                 ` Oleg Nesterov
2014-10-17 16:20                   ` Michal Hocko
2014-10-20 15:17                   ` Michal Hocko
2014-10-20 17:40                     ` Oleg Nesterov
2014-10-17 15:24               ` + freezer-check-oom-kill-while-being-frozen.patch added to -mm tree Oleg Nesterov
2014-10-17 16:07                 ` Michal Hocko
2014-10-17  6:59 ` Michal Hocko
2014-10-17 15:31   ` Oleg Nesterov
2014-10-17 16:06     ` Michal Hocko
  -- strict thread matches above, loose matches on Subject: below --
2014-10-14 22:07 akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.