All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: LKML <linux-kernel@vger.kernel.org>,
	David Rientjes <rientjes@google.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Tejun Heo <tj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Patch v4 1/2] freezer: check OOM kill while being frozen
Date: Tue, 16 Sep 2014 15:58:40 -0700	[thread overview]
Message-ID: <CAM_iQpW3ObZj9ieGJpp32+WY5A82S4LoaRYoh0KCiOQqsHJpyw@mail.gmail.com> (raw)
In-Reply-To: <20140915112218.GB19976@dhcp22.suse.cz>

On Mon, Sep 15, 2014 at 4:22 AM, Michal Hocko <mhocko@suse.cz> wrote:
> On Thu 04-09-14 15:30:41, Cong Wang wrote:
>> There is a race condition between OOM killer and freezer when
>> they try to operate on the same process, something like below:
>>
>>         Process A       Process B               Process C
>> trigger page fault
>> then trigger oom
>> B=oom_scan_process_thread()
>>                                         cgroup freezer freeze(A, B)
>>                         ...
>>                         try_to_freeze()
>>                         stay in D state
>> oom_kill_process(B)
>> restart page fault
>> ...
>>
>> In this case, process A triggered a page fault in user-space,
>> and the kernel page fault handler triggered OOM, then kernel
>> selected process B as the victim, right before being killed
>> process B was frozen by process C therefore went to D state,
>> then kernel sent SIGKILL but it is already too late as
>> process B will not care about pending signals any more.
>
> I have just got back to this patch again and I guess that the
> description is a bit misleading. Sure there is a race but the main
> problem is that frozen tasks are OOM unkillable in principle. So a task
> might hide into the fridge and livelock OOM killer. This has been broken
> since __thaw_task doesn't thaw anything (I guess it was a3201227f803
> which broke it).
>
> What do you think about the following changelog instead?
> "
> 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)
> Cc: stable@vger.kernel.org # 3.3+
> "


Yes, looks better to me.


>
> + cgroup_freezing check can go away.

With your patch, yes.

Thanks.

      reply	other threads:[~2014-09-16 22:58 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04 22:30 [Patch v4 1/2] freezer: check OOM kill while being frozen Cong Wang
2014-09-04 22:30 ` [Patch v4 2/2] freezer: remove obsolete comments in __thaw_task() Cong Wang
2014-09-05  9:45   ` Michal Hocko
2014-09-05 14:09   ` Tejun Heo
2014-09-05 14:08 ` [Patch v4 1/2] freezer: check OOM kill while being frozen Tejun Heo
2014-09-05 16:31   ` Cong Wang
2014-09-05 18:00     ` Tejun Heo
2014-09-05 18:12       ` Cong Wang
2014-09-05 22:45         ` Tejun Heo
2014-09-05 23:32           ` Rafael J. Wysocki
2014-09-08 17:40             ` Cong Wang
2014-09-08 20:54               ` Rafael J. Wysocki
2014-09-08 20:58                 ` Cong Wang
2014-09-08 21:53                   ` Rafael J. Wysocki
2014-09-08 22:22                     ` Tejun Heo
2014-09-08 22:48                       ` Rafael J. Wysocki
2014-09-08 22:50                         ` Tejun Heo
2014-09-08 23:15                           ` Rafael J. Wysocki
2014-09-08 23:00                             ` Cong Wang
2014-09-08 23:23                               ` Rafael J. Wysocki
2014-09-08 23:16                                 ` Cong Wang
2014-09-08 23:42                                   ` Rafael J. Wysocki
2014-09-08 23:29                                     ` Cong Wang
2014-09-08 23:59                                       ` Rafael J. Wysocki
2014-09-10 20:30                                       ` Cong Wang
2014-09-10 23:38                                         ` Rafael J. Wysocki
2014-09-10 23:20                                           ` Cong Wang
2014-09-11 16:30                                         ` Michal Hocko
2014-09-12 23:59                                           ` Tejun Heo
2014-09-14 16:43                                             ` Rafael J. Wysocki
2014-09-15  0:56                                               ` Tejun Heo
2014-09-15  3:34                                                 ` Rafael J. Wysocki
2014-09-15  9:36                                                   ` Michal Hocko
2014-09-16 22:55                                                     ` Cong Wang
2014-09-22  8:21                                                       ` Michal Hocko
2014-09-09 15:16                           ` Michal Hocko
2014-09-09 15:23                             ` Tejun Heo
2014-09-09 16:06                               ` Michal Hocko
2014-09-09 16:46                                 ` Tejun Heo
2014-09-09 17:12                                   ` Michal Hocko
2014-09-09 20:53                                   ` Rafael J. Wysocki
2014-09-10 13:24                                     ` Michal Hocko
2014-09-11 13:08                                       ` Michal Hocko
2014-09-11 14:17                                         ` Rafael J. Wysocki
2014-09-11 14:04                                           ` Michal Hocko
2014-09-11 14:26                                             ` Rafael J. Wysocki
2014-09-11 14:10                                               ` Michal Hocko
2014-09-11 14:32                                                 ` Rafael J. Wysocki
2014-09-11 14:28                                                   ` Michal Hocko
2014-09-11 14:52                                                     ` Rafael J. Wysocki
2014-09-11 14:45                                                       ` Michal Hocko
2014-09-14 16:39                                                         ` Rafael J. Wysocki
2014-09-12 23:48                                       ` Tejun Heo
2014-09-15 14:28                                         ` Michal Hocko
2014-09-16  5:56                                           ` Tejun Heo
2014-09-09 20:48                               ` Rafael J. Wysocki
2014-09-10  5:21                                 ` Cong Wang
2014-09-05 16:43   ` Cong Wang
2014-09-05 16:54     ` Michal Hocko
2014-09-15 11:22 ` Michal Hocko
2014-09-16 22:58   ` Cong Wang [this message]

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=CAM_iQpW3ObZj9ieGJpp32+WY5A82S4LoaRYoh0KCiOQqsHJpyw@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=rientjes@google.com \
    --cc=rjw@rjwysocki.net \
    --cc=tj@kernel.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 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.