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

From: Li Zefan
Date: Wed Dec 17 2008 - 04:13:08 EST


> +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);
> }

--
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/