From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Daniel Lezcano <daniel.lezcano-GANU6spQydw@public.gmane.org>
Cc: Linux Containers
<containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: Re: cgroup attach/fork hooks consistency with the ns_cgroup
Date: Wed, 17 Jun 2009 16:26:14 -0500 [thread overview]
Message-ID: <20090617212614.GA26781@us.ibm.com> (raw)
In-Reply-To: <4A390D5D.5040702-GANU6spQydw@public.gmane.org>
Quoting Daniel Lezcano (daniel.lezcano-GANU6spQydw@public.gmane.org):
> Hi,
>
> I noticed two different behaviours, the second one looks weird for me:
>
> 1) when the cgroup is manually created:
> mkdir /cgroup/foo
> echo $$ > /cgroup/foo/tasks
>
> only the "attach" callback is called as expected.
>
> 2) when the cgroup is automatically created via the ns_cgroup with the
> clone function and the namespace flags,
>
> the "attach" *and* the "fork" callbacks are called.
>
>
> IMHO, these two different behaviours look inconsistent. Won't this lead
> to some problems or a specific code to handle both cases if a cgroup is
> using the fork and the attach hooks ?
>
> For example, let's imagine we create a control group which shows the
> number of tasks running. We have a global atomic and we display its
> value in the cgroupfs.
>
> When a task attaches to the cgroup, we do atomic_inc in the attach
> callback. For all its child, the fork hook will do atomic_inc and exit
> hook will do atomic_dec.
>
> If we create the cgroup manually like the case 1) that works. But if we
> use the control group with the ns_cgroup the task counter will be set to
> 2 for the first tasks entering the cgroup because the attach callback
> will increment the counter and the fork callback will increment it again.
>
> In attachment a source code to illustrate the example.
>
> Shouldn't the ns_cgroup_clone be called after the cgroup_fork_callbacks
> in copy_process function ? So we don't call the fork callback for the
> first tasks and we keep the consistency ?
The ns cgroup is really only good for preventing root in a container
from escaping its cgroup-imposed limits. The same can be done today
using smack or selinux, and eventually will be possible using user
namespaces. Would anyone object to removing ns_cgroup?
It won't just remove kernel/ns_cgroup.c, but some subtle code in
fork.c, nsproxy.c, and of course cgroup.c as well.
There admittedly is minute convenience gain in not having to
manually create a new cgroup and attach a cloned child to it, but
that wasn't the intent of the cgroup.
-serge
next prev parent reply other threads:[~2009-06-17 21:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-17 15:35 cgroup attach/fork hooks consistency with the ns_cgroup Daniel Lezcano
[not found] ` <4A390D5D.5040702-GANU6spQydw@public.gmane.org>
2009-06-17 21:26 ` Serge E. Hallyn [this message]
[not found] ` <20090617212614.GA26781-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-06-18 1:21 ` Li Zefan
2009-06-18 1:21 ` Paul Menage
[not found] ` <6599ad830906171821v3c97f176y65bd4b7fa9a405e9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-18 13:45 ` Serge E. Hallyn
[not found] ` <20090618134527.GA3186-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-06-18 18:36 ` Daniel Lezcano
[not found] ` <4A3A891C.8020305-GANU6spQydw@public.gmane.org>
2009-06-18 18:41 ` Paul Menage
[not found] ` <6599ad830906181141w1669d154j22277070ae221a76-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-18 20:08 ` Daniel Lezcano
[not found] ` <4A3A9ECD.9040908-GANU6spQydw@public.gmane.org>
2009-06-19 13:59 ` Serge E. Hallyn
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=20090617212614.GA26781@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=daniel.lezcano-GANU6spQydw@public.gmane.org \
--cc=menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox