2014-04-14 15:46:06

by Vivek Goyal

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

On Thu, Mar 27, 2014 at 10:40:49PM -0400, Tejun Heo wrote:

[..]
> This patchset finally implements the default unified hierarchy. The
> goal is providing enough flexibility while enforcing stricter common
> structure where appropriate to address the above listed issues.
>
> Controllers which aren't bound to other hierarchies are
> automatically attached to the unified hierarchy,

Hi Tejun,

So this patchset does not *enforce* a single hierarchy? So user space
can still mount other hierarchies.

> which is different in
> that controllers are enabled explicitly for each subtree.
> "cgroup.subtree_control" controls which controllers are enabled on the
> child cgroups. Let's assume a hierarchy like the following.
>
> root - A - B - C
> \ D
>
> root's "cgroup.subtree_control" determines which controllers are
> enabled on A. A's on B. B's on C and D. This coincides with the
> fact that controllers on the immediate sub-level are used to
> distribute the resources of the parent. In fact, it's natural to
> assume that resource control knobs of a child belong to its parent.
> Enabling a controller in "cgroup.subtree_control" declares that
> distribution of the respective resources of the cgroup will be
> controlled. Note that this means that controller enable states are
> shared among siblings.
>
> The default hierarchy has an extra restriction - only cgroups which
> don't contain any task may have controllers enabled in
> "cgroup.subtree_control". Combined with the other properties of the
> default hierarchy, this guarantees that, from the view point of
> controllers, tasks are only on the leaf cgroups. In other words, only
> leaf csses may contain tasks. This rules out situations where child
> cgroups compete against internal tasks of the parent.

How does this work for root's tasks now? Given that task can only be
in leaf cgroups, that means tasks can't be in / cgroup (If one wants
to create some cgroups). Does that mean / will be empty and init system
need to setup things right.

Before one can create child cgroups, there will be some processes
already running (init itlsef, kernel threads etc). I am assuming they
will be running in /. So how would that work.

Thanks
Vivek


2014-04-14 17:52:43

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

Hello,

On Mon, Apr 14, 2014 at 11:45:56AM -0400, Vivek Goyal wrote:
> So this patchset does not *enforce* a single hierarchy? So user space
> can still mount other hierarchies.

Nope, nothing is forced. Controllers may be moved between unified and
traditional multiple hierarchies.

> How does this work for root's tasks now? Given that task can only be
> in leaf cgroups, that means tasks can't be in / cgroup (If one wants
> to create some cgroups). Does that mean / will be empty and init system
> need to setup things right.

Root is exempt from the restriction. Root has always been special
anyway.

I'll soon post a document describing the design and restrictions of
unified hierarchy along with an updated version of this patchset.

Thanks.

--
tejun

2014-04-14 18:15:00

by Vivek Goyal

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

On Mon, Apr 14, 2014 at 01:52:36PM -0400, Tejun Heo wrote:
> Hello,
>
> On Mon, Apr 14, 2014 at 11:45:56AM -0400, Vivek Goyal wrote:
> > So this patchset does not *enforce* a single hierarchy? So user space
> > can still mount other hierarchies.
>
> Nope, nothing is forced. Controllers may be moved between unified and
> traditional multiple hierarchies.

So is this an intermediate mode before we move to single hiearchy *only*
mode. AFAIK, you had mentioned that we will support legacy multiple
hiearchy mode but single hiearchy is the new default mode.

How does one figure out which one is unified hiearchy (out of multiple
hierarchies). Is there a flag somewhere? Or sane flag will be used to
mark unified hiearchy.

>
> > How does this work for root's tasks now? Given that task can only be
> > in leaf cgroups, that means tasks can't be in / cgroup (If one wants
> > to create some cgroups). Does that mean / will be empty and init system
> > need to setup things right.
>
> Root is exempt from the restriction. Root has always been special
> anyway.

So task and child groups can co-exist in root *only*?

>
> I'll soon post a document describing the design and restrictions of
> unified hierarchy along with an updated version of this patchset.

That would help a lot in understanding various modes and that in
turn will help with patch reviews too.

Thanks
Vivek

2014-04-14 19:21:47

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

Hello,

On Mon, Apr 14, 2014 at 02:14:21PM -0400, Vivek Goyal wrote:
> So is this an intermediate mode before we move to single hiearchy *only*
> mode. AFAIK, you had mentioned that we will support legacy multiple
> hiearchy mode but single hiearchy is the new default mode.

Hmmm? It's a separate special hierarchy which can co-exist with other
hierarchies. There's no inherent intermediacy to it. As long as
traditional hierarchies exist, it's gonna be like this.

> How does one figure out which one is unified hiearchy (out of multiple
> hierarchies). Is there a flag somewhere? Or sane flag will be used to
> mark unified hiearchy.

You can tell it multiple ways - from its mount options, whether
cgroup.controllers exists, but it'll most likely be mounted on a
distinctive mount point, wouldn't it?

> So task and child groups can co-exist in root *only*?

Note that the restriction doesn't apply if no controller is enabled
but yes root is the only cgroup where tasks can exist and controllers
are enabled at the same time.

Thanks.

--
tejun

2014-04-15 02:59:14

by Zefan Li

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

on 2014/4/15 3:21, Tejun Heo wrote:
> Hello,
>
> On Mon, Apr 14, 2014 at 02:14:21PM -0400, Vivek Goyal wrote:
>> So is this an intermediate mode before we move to single hiearchy *only*
>> mode. AFAIK, you had mentioned that we will support legacy multiple
>> hiearchy mode but single hiearchy is the new default mode.
>
> Hmmm? It's a separate special hierarchy which can co-exist with other
> hierarchies. There's no inherent intermediacy to it. As long as
> traditional hierarchies exist, it's gonna be like this.
>

I know we should allow multiple hierarchies, but why we allow this even
if sane_behavior is specified?

Like this:

# mount -t cgroup -o cpuset,__DEVEL__sane_behavior xxx /cgroup
# mount -t cgroup -o __DEVEL__sane_behavior xxx /cgroup2/

2014-04-15 04:57:47

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

Hello,

On Tue, Apr 15, 2014 at 10:58:24AM +0800, Li Zefan wrote:
> I know we should allow multiple hierarchies, but why we allow this even
> if sane_behavior is specified?

Oh, because we didn't have unified hierarchy before. The whole
sane_behavior thing is gonna go away. It'll be absorbed into unified
hierarchy and probably be handled as a separate filesystem type, so
the current situation is transitional.

Thanks.

--
tejun

2014-04-30 10:57:54

by Raghavendra K T

[permalink] [raw]
Subject: Re: [PATCHSET cgroup/for-3.15] cgroup: implement unified hierarchy

On Mon, Apr 14, 2014 at 11:22 PM, Tejun Heo <[email protected]> wrote:
>> How does this work for root's tasks now? Given that task can only be
>> in leaf cgroups, that means tasks can't be in / cgroup (If one wants
>> to create some cgroups). Does that mean / will be empty and init system
>> need to setup things right.
>
> Root is exempt from the restriction. Root has always been special
> anyway.
>

(I do not wish to Hijack this thread, but found a relevant context
here to initiate discussion. But would discuss in a separate thread
once I get a positive go on the topic)

Hi Tejun,

For some controllers like cpuset, when we have exclusive_cpu is set,
what about having a knob in the cpuset controller
to move the task to non-root (when option is set).

Because all the way along, though we have freedom to make the cpusets
exclusive and move tasks (say VMs) into them,
making sure they do not interfere with each other, we can not prevent
the other tasks spawned in a system eating into cpus of
exclusive cpuset since they go to root automatically.

Do you think having a knob, to make sure new tasks spawned go to say a
default directory under root makes sense?

I understand that we could easily have a userspace script which could
achieve intended goal, but kernel solution
would really make the exclusive cpusets have exclusive access to cpus
it should have.

(I also have a POC implemented for pre-unified hierarchy tree and
understand some bit of complications involved in that and
understand that we should not have complex policies in kernel for e.g.
filtering tasks based on patterns etc..).