Re: [PATCH] Make cgroup_path() RCU-safe

Li Zefan
2008-12-17T09:13:09Z

> +static void free_cgroup_rcu(struct rcu_head *obj)
> +{
> + struct cgroup *cgrp = container_of(obj, struct cgroup, rcu_head);
> + /*
> + * Drop the active superblock reference that we took when we
> + * created the cgroup
> + */
> + deactivate_super(cgrp->root->sb);
> +
> + kfree(cgrp);
> +}

I just wrote a different test program, and triggered kernel panic immediately:
for ((; ;))
{
mount -t cgroup -o cpu xxx /mnt
mkdir /mnt/0
rmdir /mnt/0
umount /mnt
}

I know little about vfs internal, but it seems wrong to call deactivate_super()
here. I tried to call deactivate_super() before call_rcu(), and ran 2 test
programs simultaneously, and my box are working find.

> +
> static void cgroup_diput(struct dentry *dentry, struct inode *inode)
> {
> /* is dentry a directory ? if so, kfree() associated cgroup */
> @@ -620,11 +632,7 @@ static void cgroup_diput(struct dentry *dentry,
> struct inode *inode)
> cgrp->root->number_of_cgroups--;
> mutex_unlock(&cgroup_mutex);
>
> - /* Drop the active superblock reference that we took when we
> - * created the cgroup */
> - deactivate_super(cgrp->root->sb);
> -
> - kfree(cgrp);
> + call_rcu(&cgrp->rcu_head, free_cgroup_rcu);
> }
> iput(inode);
> }