From: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
To: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
"akpm >> Andrew Morton"
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Stephane Eranian
<eranian-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 2/7] cgroups: Allow to bind a subsystem to a cgroup hierarchy
Date: Mon, 25 Oct 2010 09:23:00 +0800 [thread overview]
Message-ID: <4CC4DBF4.1030405@cn.fujitsu.com> (raw)
In-Reply-To: <20101022213819.GK10119-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
>> +/*
>> + * cgroup_walk_herarchy - iterate through a cgroup hierarchy
>> + * @process_cgroup: callback called on each cgroup in the hierarchy
>> + * @data: will be passed to @process_cgroup
>> + * @top_cgrp: the root cgroup of the hierarchy
>> + *
>> + * For such a hierarchy:
>> + * a1 c1
>> + * / /
>> + * Root - a2 - b1 - c2
>> + * \
>> + * a3
>> + *
>> + * The iterating order is: a1, a2, b1, c1, c2, a3. So a parent will be
>> + * processed before its children.
>> + */
>
> You could just say it's a depth-first walk except we process the parent before
> its children.
>
Will revise the comment. A diagram is intuitive. :)
>> +static int cgroup_walk_hierarchy(int (*process_cgroup)(struct cgroup *, void *),
>> + void *data, struct cgroup *top_cgrp)
>
> <snip>
>
>> +static int hierarchy_populate_dir(struct cgroup *cgrp, void *data)
>> +{
>> + mutex_lock_nested(&cgrp->dentry->d_inode->i_mutex, I_MUTEX_CHILD);
>> + cgroup_populate_dir(cgrp);
>> + mutex_unlock(&cgrp->dentry->d_inode->i_mutex);
>> + return 0;
>> +}
>> +
>> /*
>> * Call with cgroup_mutex held. Drops reference counts on modules, including
>> * any duplicate ones that parse_cgroupfs_options took. If this function
>> @@ -945,36 +1079,53 @@ static int rebind_subsystems(struct cgroupfs_root *root,
>> unsigned long added_bits, removed_bits;
>> struct cgroup *cgrp = &root->top_cgroup;
>> int i;
>> + int err;
>>
>> BUG_ON(!mutex_is_locked(&cgroup_mutex));
>>
>> removed_bits = root->actual_subsys_bits & ~final_bits;
>> added_bits = final_bits & ~root->actual_subsys_bits;
>> +
>> /* Check that any added subsystems are currently free */
>> - for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
>> - unsigned long bit = 1UL << i;
>> - struct cgroup_subsys *ss = subsys[i];
>> - if (!(bit & added_bits))
>> - continue;
>> + for_each_set_bit(i, &added_bits, CGROUP_SUBSYS_COUNT) {
>> /*
>> * Nobody should tell us to do a subsys that doesn't exist:
>> * parse_cgroupfs_options should catch that case and refcounts
>> * ensure that subsystems won't disappear once selected.
>> */
>> - BUG_ON(ss == NULL);
>> - if (ss->root != &rootnode) {
>> + BUG_ON(subsys[i] == NULL);
>> + if (subsys[i]->root != &rootnode) {
>> /* Subsystem isn't free */
>> return -EBUSY;
>> }
>> }
>>
>> - /* Currently we don't handle adding/removing subsystems when
>> - * any child cgroups exist. This is theoretically supportable
>> - * but involves complex error handling, so it's being left until
>> - * later */
>> - if (root->number_of_cgroups > 1)
>> + /* removing will be supported later */
>> + if (root->number_of_cgroups > 1 && removed_bits)
>> return -EBUSY;
>>
>> + if (root->number_of_cgroups > 1) {
>
> Is there something wrong with the indentation here? I can't
> see the closing brace for the "if (root->number_of_cgroups > 1)"
> that should precede the for_each_set_bit() loop below.
>
Oops, I must have forgot to commit the change when I fixed this.
>> + for_each_set_bit(i, &added_bits, CGROUP_SUBSYS_COUNT)
>> + if (!subsys[i]->can_bind)
>> + return -EBUSY;
>
> I think you could avoid the can_bind flag field entirely and do:
>
> if (!subsys[i]->bind)
>
Nope. For some subsystems we just set the flag and need not to
provide a bind() callback.
> Also, if we're going with my "split out unbind" suggestion I think
> the part here would be:
>
> for_each_set_bit(i, &removed_bits, CGROUP_SUBSYS_COUNT)
> if (!subsys[i]->unbind)
> return -EBUSY;
>
next prev parent reply other threads:[~2010-10-25 1:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4CC146A4.9090505@cn.fujitsu.com>
[not found] ` <4CC146A4.9090505-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-22 8:09 ` [PATCH 1/7] cgroups: Shrink struct cgroup_subsys Li Zefan
2010-10-22 8:09 ` [PATCH 2/7] cgroups: Allow to bind a subsystem to a cgroup hierarchy Li Zefan
[not found] ` <4CC146D4.7030009-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-22 12:47 ` Peter Zijlstra
2010-10-22 21:38 ` Matt Helsley
2010-10-28 23:55 ` Paul Menage
[not found] ` <AANLkTimCD90s+y_6y=LyOL1QqEOOAaT+b2b4guDrzo_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-08 5:26 ` Li Zefan
[not found] ` <1287751631.15336.33.camel@twins>
2010-10-25 0:59 ` Li Zefan
[not found] ` <20101022213819.GK10119@count0.beaverton.ibm.com>
[not found] ` <20101022213819.GK10119-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-10-25 1:23 ` Li Zefan [this message]
2010-10-28 23:57 ` Paul Menage
2010-10-22 8:10 ` [PATCH 3/7] cgroups: Allow to unbind subsystem from a cgroup hierarachy Li Zefan
2010-10-22 8:11 ` [PATCH 4/7] cgroups: Mark some subsystems bindable Li Zefan
2010-10-22 8:11 ` [PATCH 5/7] cgroups: Make freezer subsystem bindable Li Zefan
2010-10-22 8:12 ` [PATCH 6/7] cgroups: Warn if a bindable subsystem calls css_get() Li Zefan
2010-10-22 8:12 ` [PATCH 7/7] cgroups: Update documentation for bindable subsystems Li Zefan
2010-10-22 12:50 ` [PATCH 0/7] cgroups: Allow to bind/unbind subsystems to/from non-trival hierarchy Peter Zijlstra
[not found] ` <4CC1473D.9070201@cn.fujitsu.com>
[not found] ` <4CC1473D.9070201-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-22 20:57 ` [PATCH 5/7] cgroups: Make freezer subsystem bindable Matt Helsley
[not found] ` <20101022205755.GJ10119-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-10-22 21:46 ` Matt Helsley
2010-10-22 21:57 ` Matt Helsley
2010-10-25 1:15 ` Li Zefan
[not found] ` <20101022214650.GL10119@count0.beaverton.ibm.com>
[not found] ` <20101022214650.GL10119-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-10-29 0:06 ` Paul Menage
[not found] ` <4CC14769.2000406@cn.fujitsu.com>
[not found] ` <4CC14769.2000406-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-25 0:36 ` [PATCH 7/7] cgroups: Update documentation for bindable subsystems KAMEZAWA Hiroyuki
2010-10-29 0:13 ` Paul Menage
[not found] ` <20101025093617.7de750c0.kamezawa.hiroyu@jp.fujitsu.com>
[not found] ` <20101025093617.7de750c0.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2010-10-25 0:52 ` Li Zefan
[not found] ` <4CC4D4B9.3020807@cn.fujitsu.com>
[not found] ` <4CC4D4B9.3020807-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-25 0:56 ` Li Zefan
[not found] ` <AANLkTinbtLkF=haFeDkzecEWv_FE9jG4TefiptSnZcPi@mail.gmail.com>
[not found] ` <AANLkTinbtLkF=haFeDkzecEWv_FE9jG4TefiptSnZcPi-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-29 0:15 ` Paul Menage
2010-11-08 5:27 ` Li Zefan
[not found] ` <1287751801.15336.35.camel@twins>
2010-10-25 1:07 ` [PATCH 0/7] cgroups: Allow to bind/unbind subsystems to/from non-trival hierarchy Li Zefan
[not found] ` <4CC4D84C.5000705@cn.fujitsu.com>
[not found] ` <4CC4D84C.5000705-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-28 23:33 ` Paul Menage
[not found] ` <4CC146BA.7080009@cn.fujitsu.com>
[not found] ` <4CC146BA.7080009-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-28 23:34 ` [PATCH 1/7] cgroups: Shrink struct cgroup_subsys Paul Menage
[not found] ` <AANLkTikf-1kLStxqi5UjP=vn3pqVBHy0OA7ibeWTkJ5z@mail.gmail.com>
[not found] ` <AANLkTikf-1kLStxqi5UjP=vn3pqVBHy0OA7ibeWTkJ5z-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-08 5:23 ` Li Zefan
[not found] ` <4CD78946.5060405@cn.fujitsu.com>
[not found] ` <4CD78946.5060405-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-11-09 21:05 ` Paul Menage
[not found] ` <AANLkTim6d1fQLZbkmZST3PTN0RMSs3m=oossF81pYBn9@mail.gmail.com>
[not found] ` <AANLkTim6d1fQLZbkmZST3PTN0RMSs3m=oossF81pYBn9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-10 0:52 ` Li Zefan
[not found] ` <4CD9ECD2.3030805@cn.fujitsu.com>
[not found] ` <4CD9ECD2.3030805-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-11-10 1:53 ` Paul Menage
[not found] ` <AANLkTinMr7VE4Os7rXWjiHWOVysv=oE0vHKduLWCN0bC@mail.gmail.com>
[not found] ` <AANLkTinMr7VE4Os7rXWjiHWOVysv=oE0vHKduLWCN0bC-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-10 2:06 ` Li Zefan
[not found] ` <4CD9FE2D.2070108@cn.fujitsu.com>
[not found] ` <4CD9FE2D.2070108-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-11-10 2:15 ` Paul Menage
[not found] ` <4CC146F5.9060006@cn.fujitsu.com>
[not found] ` <4CC146F5.9060006-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-29 0:02 ` [PATCH 3/7] cgroups: Allow to unbind subsystem from a cgroup hierarachy Paul Menage
[not found] ` <4CC14756.5010504@cn.fujitsu.com>
[not found] ` <4CC14756.5010504-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-10-29 0:05 ` [PATCH 6/7] cgroups: Warn if a bindable subsystem calls css_get() Paul Menage
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=4CC4DBF4.1030405@cn.fujitsu.com \
--to=lizf-bthxqxjhjhxqfuhtdcdx3a@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=eranian-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matthltc-r/Jw6+rmf7HQT0dZR+AlfA@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