Re: [PATCH] cgroups: don't put struct cgroupfs_root protected by RCU

From: Paul Menage
Date: Fri Nov 21 2008 - 14:01:41 EST


On Fri, Nov 21, 2008 at 12:49 AM, Lai Jiangshan <laijs@xxxxxxxxxxxxxx> wrote:
>
> we don't access struct cgroupfs_root in fast path,
> so we should not put struct cgroupfs_root protected by RCU
>
> but the comment in struct cgroup_subsys.root confuse us.
>
> struct cgroup_subsys.root is used in these places:
>
> 1 find_css_set(): if (ss->root->subsys_list.next == &ss->sibling)
> 2 rebind_subsystems(): if (ss->root != &rootnode)
> rcu_assign_pointer(ss->root, root);
> rcu_assign_pointer(subsys[i]->root, &rootnode);
> 3 cgroup_has_css_refs(): if (ss->root != cgrp->root)
> 4 cgroup_init_subsys(): ss->root = &rootnode;
> 5 proc_cgroupstats_show(): ss->name, ss->root->subsys_bits,
> ss->root->number_of_cgroups, !ss->disabled);
> 6 cgroup_clone(): root = subsys->root;
> if ((root != subsys->root) ||
>
> all these place we have held cgroup_lock() or we don't dereference to
> struct cgroupfs_root. It's means wo don't need RCU when use
> struct cgroup_subsys.root, and we should not put struct cgroupfs_root
> protected by RCU.
>
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>

Reviewed-by: Paul Menage <menage@xxxxxxxxxx>

Thanks, seems reasonable.

> ---
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index 1164963..22901ff 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -343,7 +345,6 @@ struct cgroup_subsys {
> #define MAX_CGROUP_TYPE_NAMELEN 32
> const char *name;
>
> - /* Protected by RCU */
> struct cgroupfs_root *root;
>
> struct list_head sibling;
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 358e775..ddc10ac 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -717,7 +722,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
> cgrp->subsys[i] = dummytop->subsys[i];
> cgrp->subsys[i]->cgroup = cgrp;
> list_add(&ss->sibling, &root->subsys_list);
> - rcu_assign_pointer(ss->root, root);
> + ss->root = root;
> if (ss->bind)
> ss->bind(ss, cgrp);
>
> @@ -729,7 +734,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
> ss->bind(ss, dummytop);
> dummytop->subsys[i]->cgroup = dummytop;
> cgrp->subsys[i] = NULL;
> - rcu_assign_pointer(subsys[i]->root, &rootnode);
> + subsys[i]->root = &rootnode;
> list_del(&ss->sibling);
> } else if (bit & final_bits) {
> /* Subsystem state should already exist */
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/