From: Michal Hocko <mhocko@suse.cz>
To: Tejun Heo <tj@kernel.org>
Cc: lizefan@huawei.com, rjw@sisk.pl,
containers@lists.linux-foundation.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
fweisbec@gmail.com, Glauber Costa <glommer@parallels.com>
Subject: Re: [PATCH 1/9] cgroup: add cgroup_subsys->post_create()
Date: Wed, 7 Nov 2012 16:25:16 +0100 [thread overview]
Message-ID: <20121107152516.GA4131@dhcp22.suse.cz> (raw)
In-Reply-To: <1351931915-1701-2-git-send-email-tj@kernel.org>
On Sat 03-11-12 01:38:27, Tejun Heo wrote:
> Currently, there's no way for a controller to find out whether a new
> cgroup finished all ->create() allocatinos successfully and is
> considered "live" by cgroup.
>
> This becomes a problem later when we add generic descendants walking
> to cgroup which can be used by controllers as controllers don't have a
> synchronization point where it can synchronize against new cgroups
> appearing in such walks.
>
> This patch adds ->post_create(). It's called after all ->create()
> succeeded and the cgroup is linked into the generic cgroup hierarchy.
> This plays the counterpart of ->pre_destroy().
Hmm, I had to look at "cgroup_freezer: implement proper hierarchy
support" to actually understand what is the callback good for. The above
sounds as if the callback is needed when a controller wants to use
the new iterators or when pre_destroy is defined.
I think it would be helpful if the changelog described that the callback
is needed when the controller keeps a mutable shared state for the
hierarchy. For example memory controller doesn't have any such a strict
requirement so we can safely use your new iterators without pre_destroy.
Anyway, I like this change because the shared state is now really easy
to implement.
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Glauber Costa <glommer@parallels.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
> ---
> include/linux/cgroup.h | 1 +
> kernel/cgroup.c | 12 ++++++++++--
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index fe876a7..b442122 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -438,6 +438,7 @@ int cgroup_taskset_size(struct cgroup_taskset *tset);
>
> struct cgroup_subsys {
> struct cgroup_subsys_state *(*create)(struct cgroup *cgrp);
> + void (*post_create)(struct cgroup *cgrp);
> void (*pre_destroy)(struct cgroup *cgrp);
> void (*destroy)(struct cgroup *cgrp);
> int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index e3045ad..f05d992 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -4060,10 +4060,15 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
> if (err < 0)
> goto err_remove;
>
> - /* each css holds a ref to the cgroup's dentry */
> - for_each_subsys(root, ss)
> + for_each_subsys(root, ss) {
> + /* each css holds a ref to the cgroup's dentry */
> dget(dentry);
>
> + /* creation succeeded, notify subsystems */
> + if (ss->post_create)
> + ss->post_create(cgrp);
> + }
> +
> /* The cgroup directory was pre-locked for us */
> BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex));
>
> @@ -4281,6 +4286,9 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
>
> ss->active = 1;
>
> + if (ss->post_create)
> + ss->post_create(&ss->root->top_cgroup);
> +
> /* this function shouldn't be used with modular subsystems, since they
> * need to register a subsys_id, among other things */
> BUG_ON(ss->module);
> --
> 1.7.11.7
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2012-11-07 15:25 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-03 8:38 [PATCHSET cgroup/for-3.8] cgroup_freezer: implement proper hierarchy support Tejun Heo
2012-11-03 8:38 ` [PATCH 1/9] cgroup: add cgroup_subsys->post_create() Tejun Heo
2012-11-05 13:42 ` Glauber Costa
2012-11-05 18:02 ` [RFC] cgroup: deprecate clone_children Tejun Heo
2012-11-05 19:17 ` Serge Hallyn
2012-11-05 19:26 ` Tejun Heo
2012-11-07 15:25 ` Michal Hocko [this message]
2012-11-07 17:02 ` [PATCH 1/9] cgroup: add cgroup_subsys->post_create() Tejun Heo
2012-11-07 17:15 ` [PATCH 1/9 v2] " Tejun Heo
2012-11-07 17:40 ` Michal Hocko
2012-11-08 2:59 ` Kamezawa Hiroyuki
2012-11-08 19:07 ` [PATCH 1/9 v3] " Tejun Heo
2012-11-09 9:09 ` Li Zefan
2012-11-09 9:09 ` Li Zefan
2012-11-09 11:09 ` Daniel Wagner
2012-11-09 17:22 ` Tejun Heo
2012-11-10 1:35 ` Glauber Costa
2012-11-12 13:04 ` Daniel Wagner
2012-11-03 8:38 ` [PATCH 2/9] cgroup: Use rculist ops for cgroup->children Tejun Heo
2012-11-07 15:30 ` Michal Hocko
2012-11-08 3:01 ` Kamezawa Hiroyuki
2012-11-09 9:10 ` Li Zefan
2012-11-03 8:38 ` [PATCH 3/9] cgroup: implement generic child / descendant walk macros Tejun Heo
2012-11-06 20:31 ` Tejun Heo
2012-11-07 15:38 ` Michal Hocko
2012-11-07 16:54 ` Michal Hocko
2012-11-07 17:01 ` Tejun Heo
2012-11-07 17:49 ` Michal Hocko
2012-11-08 3:21 ` Kamezawa Hiroyuki
2012-11-08 9:50 ` Michal Hocko
2012-11-08 17:15 ` Tejun Heo
2012-11-08 17:59 ` [PATCH 3/9 v2] " Tejun Heo
2012-11-09 9:13 ` Li Zefan
2012-11-03 8:38 ` [PATCH 4/9] cgroup_freezer: trivial cleanups Tejun Heo
2012-11-08 3:24 ` Kamezawa Hiroyuki
2012-11-08 9:53 ` Michal Hocko
2012-11-03 8:38 ` [PATCH 5/9] cgroup_freezer: prepare freezer_change_state() for full hierarchy support Tejun Heo
2012-11-08 4:25 ` Kamezawa Hiroyuki
2012-11-08 9:56 ` Michal Hocko
2012-11-03 8:38 ` [PATCH 6/9] cgroup_freezer: make freezer->state mask of flags Tejun Heo
2012-11-08 4:37 ` Kamezawa Hiroyuki
2012-11-08 4:42 ` Tejun Heo
2012-11-08 5:00 ` Kamezawa Hiroyuki
2012-11-08 14:38 ` Tejun Heo
2012-11-08 10:39 ` Michal Hocko
2012-11-08 14:39 ` Tejun Heo
2012-11-08 14:47 ` Michal Hocko
2012-11-03 8:38 ` [PATCH 7/9] cgroup_freezer: introduce CGROUP_FREEZING_[SELF|PARENT] Tejun Heo
2012-11-08 4:42 ` Kamezawa Hiroyuki
2012-11-08 4:45 ` Tejun Heo
2012-11-08 4:56 ` Kamezawa Hiroyuki
2012-11-08 14:41 ` Tejun Heo
2012-11-08 12:47 ` Michal Hocko
2012-11-08 14:42 ` Tejun Heo
2012-11-03 8:38 ` [PATCH 8/9] cgroup_freezer: add ->post_create() and ->pre_destroy() and track online state Tejun Heo
2012-11-08 4:48 ` Kamezawa Hiroyuki
2012-11-08 15:41 ` Tejun Heo
2012-11-08 13:23 ` Michal Hocko
2012-11-08 17:17 ` Tejun Heo
2012-11-03 8:38 ` [PATCH 9/9] cgroup_freezer: implement proper hierarchy support Tejun Heo
2012-11-07 11:00 ` Michal Hocko
2012-11-07 16:31 ` Tejun Heo
2012-11-07 16:39 ` [PATCH 9/9 v2] " Tejun Heo
2012-11-08 14:08 ` Michal Hocko
2012-11-08 14:18 ` Tejun Heo
2012-11-08 15:20 ` Michal Hocko
2012-11-08 15:29 ` Tejun Heo
2012-11-08 15:57 ` Michal Hocko
2012-11-08 17:57 ` [PATCH 9/9 v3] " Tejun Heo
2012-11-08 18:02 ` Michal Hocko
2012-11-08 18:04 ` Tejun Heo
2012-11-08 18:08 ` Michal Hocko
2012-11-08 18:01 ` [PATCHSET cgroup/for-3.8] " Tejun Heo
2012-11-09 17:15 ` 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=20121107152516.GA4131@dhcp22.suse.cz \
--to=mhocko@suse.cz \
--cc=cgroups@vger.kernel.org \
--cc=containers@lists.linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=glommer@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=rjw@sisk.pl \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®