All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Roman Gushchin <guroan@gmail.com>, Tejun Heo <tj@kernel.org>,
	Kernel Team <Kernel-team@fb.com>,
	"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 4/7] cgroup: cgroup v2 freezer
Date: Mon, 11 Feb 2019 21:30:41 +0000	[thread overview]
Message-ID: <20190211213036.GA26063@tower.DHCP.thefacebook.com> (raw)
In-Reply-To: <20190130165200.GA4131@redhat.com>

On Wed, Jan 30, 2019 at 05:52:01PM +0100, Oleg Nesterov wrote:
> Hi Roman,
> 
> On 01/28, Roman Gushchin wrote:
> >
> > Yes, I think you're right: cgroup_exit() should check CGRP_FREEZE bit,
> > not CGRP_FROZEN. Like cgroup_post_fork() does (a one-liner change below).

Hi Oleg!

Sorry for the late reply, I was out of work for some time...
Now I'm fully back.

> 
> but this won't fix all problems? it seems that you missed my other concerns.
> 
> Firstly, this doesn't look consistent. Suppose a cgroup contains a single
> process sleeping in ptrace_stop(). Then it becomes CGRP_FROZEN right after
> "echo 1 > cgroup.freeze".
> 
> OTOH. if this single task sleeps in do_freezer_trap() and gets PTRACE_INTERRUPT,
> it will equally sleep ptrace_stop() but cgroup won't be CGRP_FROZEN. Never.
> 
> Worse, this looks just wrong. In the latter case, cgroup becomes CGRP_FROZEN
> right after a 2nd task migrates to this cgroup, before this new task calls
> do_freezer_trap() or cgroup_enter_stopped().

You're right. So, it looks like the problem is in the equation
nr_tasks_frozen + nr_tasks_stopped == nr_tasks_to_freeze ,
because a task can be frozen and stopped simultaneously.

So, basically it has to be
nr_tasks_frozen + nr_tasks_stopped >= nr_tasks_to_freeze instead.

I'll cover it with an unit test, and will post v7 soon.

> 
> 
> 
> > About spurious transitions (like frozen->non frozen->frozen on a task
> > being SIGKILLed):
> > in early versions of the patchset I've tried to avoid them, but then
> > following the Tejun's advice
> > switched over to expose them to a user. The logic behind is simple: if
> > the state of the cgroup has been changed (a task is gone, for
> > example), let's notify a user.
> 
> OK, I won't argue...
> 
> actually I can't argue because I do not really understand why do we want
> a "killable" freezer, let alone ptraceable ;)

So the problem with the frozen state as in cgroup v1 that it's a very
special and "non-natural" task state, which requires special handling
in many places.

Just for an example, we're using oomd (userspace OOM handling daemon),
which selects and kills one of the workloads in case of too high memory
pressure. It should be able to kill all tasks in the selected cgroup,
but we definitely don't want to let it to fiddle with cgroup controls
to unfreeze the cgroup. Etc.

In other words, the cgroup freezer has a simple task of preventing
processes in the given cgroup to consume CPU resources. Unlike the system-wide
freezer, it shouldn't try to make a "snapshot", it just a non-goal.

Thanks!

  reply	other threads:[~2019-02-11 21:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-22  0:03 [PATCH v6 0/7] freezer for cgroup v2 Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 1/7] cgroup: rename freezer.c into legacy_freezer.c Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 2/7] cgroup: implement __cgroup_task_count() helper Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 3/7] cgroup: protect cgroup->nr_(dying_)descendants by css_set_lock Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 4/7] cgroup: cgroup v2 freezer Roman Gushchin
2019-01-25 12:27   ` Oleg Nesterov
2019-01-25 13:46     ` Oleg Nesterov
2019-01-28 19:59     ` Roman Gushchin
2019-01-30 16:52       ` Oleg Nesterov
2019-02-11 21:30         ` Roman Gushchin [this message]
2019-02-14 16:26           ` Oleg Nesterov
2019-02-14 16:41             ` Roman Gushchin
2019-01-25 13:43   ` Oleg Nesterov
2018-12-22  0:03 ` [PATCH v6 5/7] kselftests: cgroup: don't fail on cg_kill_all() error in cg_destroy() Roman Gushchin
2018-12-22  0:03   ` Roman Gushchin
2018-12-22  0:03   ` guroan
2018-12-22  0:03 ` [PATCH v6 6/7] kselftests: cgroup: add freezer controller self-tests Roman Gushchin
2018-12-22  0:03   ` Roman Gushchin
2018-12-22  0:03   ` guroan
2018-12-22  0:03 ` [PATCH v6 7/7] cgroup: document cgroup v2 freezer interface Roman Gushchin
2019-01-24 15:26 ` [PATCH v6 0/7] freezer for cgroup v2 Tejun Heo

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=20190211213036.GA26063@tower.DHCP.thefacebook.com \
    --to=guro@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=cgroups@vger.kernel.org \
    --cc=guroan@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --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.