All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Tejun Heo <tj@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -v2] freezer: check OOM kill while being frozen
Date: Fri, 17 Oct 2014 18:10:21 +0200	[thread overview]
Message-ID: <20141017161021.GC7227@redhat.com> (raw)
In-Reply-To: <20141017074654.GD8076@dhcp22.suse.cz>

On 10/17, Michal Hocko wrote:
>
> I think we should rather get back to __thaw_task here.

Yes, agreed.

> Andrew could you replace the previous version by this one, please?

Yes, that patch should be dropped...


And can't resist... please look at
http://marc.info/?l=linux-kernel&m=138427535430827 ;)

> --- a/kernel/freezer.c
> +++ b/kernel/freezer.c
> @@ -45,13 +45,28 @@ bool freezing_slow_path(struct task_struct *p)
>  	if (pm_nosig_freezing || cgroup_freezing(p))
>  		return true;
>
> -	if (pm_freezing && !(p->flags & PF_KTHREAD))
> +	if (!(p->flags & PF_KTHREAD))

Why? Doesn't this mean that try_to_freeze() can race with thaw_processes()
and then this task can be frozen for no reazon?

> +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))

I still think that the comment should tell more to explain why this
is not safe.

And if this is not safe, it is not clear how/why cgroup_freezing() can
save us, both pm_freezing and CGROUP_FREEZING can be true?

And I think that this TIF_MEMDIE should go into freezing_slow_path(),
so we do not even need should_thaw_current().

This also looks more safe to me. Suppose that a task does

	while (try_to_freeze())
		;

Yes, this is pointless but correct. And in fact I think this pattern
is possible. If this task is killed by OOM, it will spin forever.

Oleg.


  reply	other threads:[~2014-10-17 16:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20141017161021.GC7227@redhat.com \
    --to=oleg@redhat.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 \
    --cc=xiyou.wangcong@gmail.com \
    /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.