Re: [PATCH 5/9] [RFC] Remove cgroup_subsys.root pointer

From: Louis Rilling
Date: Thu Jul 02 2009 - 05:05:04 EST


On Wed, Jul 01, 2009 at 07:11:18PM -0700, Paul Menage wrote:
> [RFC] Remove cgroup_subsys.root pointer
>
> In preparation for supporting cgroup subsystems that can be bound to
> multiple hierarchies, remove the "root" pointer and associated list
> structures. Subsystem hierarchy membership is now determined entirely
> through the subsystem bitmasks in struct cgroupfs_root.
>
> Minor changes include:
> - root_list now includes the inactive root
> - for_each_active_root() -> for_each_root()
> - for_each_subsys() is now guaranteed to be in subsys_id order
>

[...]

> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index dede632..8b1b92f 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c

[...]

> @@ -191,13 +182,36 @@ static int notify_on_release(const struct cgroup *cgrp)
> * for_each_subsys() allows you to iterate on each subsystem attached to
> * an active hierarchy
> */
> +static inline struct cgroup_subsys *nth_ss(int n)
> +{
> + return (n >= CGROUP_SUBSYS_COUNT) ? NULL : subsys[n];
> +}
> #define for_each_subsys(_root, _ss) \
> -list_for_each_entry(_ss, &_root->subsys_list, sibling)
> +for (_ss = nth_ss(find_first_bit(&(_root)->subsys_bits, CGROUP_SUBSYS_COUNT));\
> + _ss != NULL; \
> + _ss = nth_ss(find_next_bit(&(_root)->subsys_bits, CGROUP_SUBSYS_COUNT, \
> + _ss->subsys_id + 1)))
>
> -/* for_each_active_root() allows you to iterate across the active hierarchies */
> -#define for_each_active_root(_root) \
> +
> +/* for_each_root() allows you to iterate across all hierarchies */
> +#define for_each_root(_root) \
> list_for_each_entry(_root, &roots, root_list)
>
> +/* Find the root for a given subsystem */
> +static struct cgroupfs_root *find_root(struct cgroup_subsys *ss)
> +{
> + int id = ss->subsys_id;
> + struct cgroupfs_root *root, *res = NULL;
> + for_each_root(root) {
> + if (root->subsys_bits && (1UL << id)) {
Should be &, not && ------------------^^

Louis

> + BUG_ON(res);
> + res = root;
> + }
> + }
> + BUG_ON(!res);
> + return res;
> +}
> +
> /* the list of cgroups eligible for automatic release. Protected by
> * release_list_lock */
> static LIST_HEAD(release_list);

[...]

--
Dr Louis Rilling Kerlabs
Skype: louis.rilling Batiment Germanium
Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes
http://www.kerlabs.com/ 35700 Rennes

Attachment: signature.asc
Description: Digital signature