From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH 6/6] cgroup: implement for_each_[builtin_]subsys()
Date: Mon, 24 Jun 2013 18:50:42 +0800 [thread overview]
Message-ID: <51C82482.9020902@huawei.com> (raw)
In-Reply-To: <1371864854-28364-7-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
On 2013/6/22 9:34, Tejun Heo wrote:
> There are quite a few places where all loaded [builtin] subsys are
> iterated. Implement for_each_[builtin_]subsys() and replace manual
> iterations with those to simplify those places a bit. The new
> iterators automatically skip NULL subsystems. This shouldn't cause
> any functional difference.
>
> Iteration loops which scan all subsystems and then skipping modular
> ones explicitly are converted to use for_each_builtin_subsys().
>
> While at it, reorder variable declarations and adjust whitespaces a
> bit in the affected functions.
>
> Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
> kernel/cgroup.c | 143 ++++++++++++++++++++++++++------------------------------
> 1 file changed, 67 insertions(+), 76 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index c4bbafb..a890b56 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -259,6 +259,27 @@ static int notify_on_release(const struct cgroup *cgrp)
> return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
> }
>
> +/**
> + * for_each_subsys - iterate all loaded cgroup subsystems
> + * @ss: the iteration cursor
> + * @i: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end
> + */
> +#define for_each_subsys(ss, i) \
This should be called with cgroup_mutex held, so how about add a comment or
a lock assert for it?
> + for ((i) = 0; (i) < CGROUP_SUBSYS_COUNT; (i)++) \
> + if (!((ss) = cgroup_subsys[i])) { } \
> + else
> +
> +/**
> + * for_each_builtin_subsys - iterate all built-in cgroup subsystems
> + * @ss: the iteration cursor
> + * @i: the index of @ss, CGROUP_BUILTIN_SUBSYS_COUNT after reaching the end
> + *
> + * Bulit-in subsystems are always present.
> + */
> +#define for_each_builtin_subsys(ss, i) \
> + for ((i) = 0; (i) < CGROUP_BUILTIN_SUBSYS_COUNT && \
> + (((ss) = cgroup_subsys[i]) || true); (i)++)
Why "true" is needed here? given ss can't be NULL.
> +
> /* iterate each subsystem attached to a hierarchy */
> #define for_each_root_subsys(root, ss) \
> list_for_each_entry((ss), &(root)->subsys_list, sibling)
> @@ -356,10 +377,11 @@ static DEFINE_HASHTABLE(css_set_table, CSS_SET_HASH_BITS);
>
=
next prev parent reply other threads:[~2013-06-24 10:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1371864854-28364-1-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-22 1:34 ` [PATCH 1/6] cgroup: convert CFTYPE_* flags to enums Tejun Heo
2013-06-22 1:34 ` [PATCH 2/6] cgroup: prefix global variables with "cgroup_" Tejun Heo
2013-06-22 1:34 ` [PATCH 3/6] cgroup: remove cgroup->actual_subsys_mask Tejun Heo
2013-06-22 1:34 ` [PATCH 4/6] cgroup: clean up find_css_set() and friends Tejun Heo
2013-06-22 1:34 ` [PATCH 5/6] cgroup: s/for_each_subsys()/for_each_root_subsys()/ Tejun Heo
2013-06-22 1:34 ` [PATCH 6/6] cgroup: implement for_each_[builtin_]subsys() Tejun Heo
2013-06-24 22:32 ` [PATCHSET cgroup/for-3.11] cgroup: miscellaneous cleanups Tejun Heo
2013-06-25 0:34 ` [PATCH 5.5/6] cgroup: move init_css_set initialization inside cgroup_mutex Tejun Heo
[not found] ` <20130625003434.GV1918-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-06-25 1:36 ` Li Zefan
[not found] ` <1371864854-28364-2-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-24 10:21 ` [PATCH 1/6] cgroup: convert CFTYPE_* flags to enums Li Zefan
[not found] ` <1371864854-28364-3-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-24 10:22 ` [PATCH 2/6] cgroup: prefix global variables with "cgroup_" Li Zefan
[not found] ` <1371864854-28364-5-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-5-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-24 10:33 ` [PATCH 4/6] cgroup: clean up find_css_set() and friends Li Zefan
[not found] ` <51C8206F.90404-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-06-24 20:03 ` Tejun Heo
[not found] ` <1371864854-28364-7-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-7-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-24 10:50 ` Li Zefan [this message]
[not found] ` <51C82482.9020902-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-06-24 20:04 ` [PATCH 6/6] cgroup: implement for_each_[builtin_]subsys() Tejun Heo
2013-06-25 0:22 ` [PATCH v2 " Tejun Heo
[not found] ` <20130625002236.GU1918-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-06-25 1:35 ` Li Zefan
[not found] ` <51C8F3EB.4090106-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-06-25 18:42 ` Tejun Heo
[not found] ` <1371864854-28364-6-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-24 10:52 ` [PATCH 5/6] cgroup: s/for_each_subsys()/for_each_root_subsys()/ Li Zefan
[not found] ` <1371864854-28364-4-git-send-email-tj@kernel.org>
[not found] ` <1371864854-28364-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-24 10:26 ` [PATCH 3/6] cgroup: remove cgroup->actual_subsys_mask Li Zefan
2013-06-24 22:30 ` [PATCH 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=51C82482.9020902@huawei.com \
--to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@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