public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Paul Menage <menage@google.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Make cgroup_path() RCU-safe
Date: Wed, 17 Dec 2008 17:11:33 +0800	[thread overview]
Message-ID: <4948C245.9000108@cn.fujitsu.com> (raw)
In-Reply-To: <6599ad830812161558t4da0e5e7l4ad7d6f3a0dfbe6e@mail.gmail.com>

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


      parent reply	other threads:[~2008-12-17  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16 23:58 [PATCH] Make cgroup_path() RCU-safe Paul Menage
2008-12-17  1:16 ` Li Zefan
2008-12-17  8:01   ` Paul Menage
2008-12-17  9:11 ` Li Zefan [this message]

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=4948C245.9000108@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    --cc=mingo@elte.hu \
    /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