From: Paul Menage <menage@google.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Containers <containers@lists.linux-foundation.org>,
Li Zefan <lizf@cn.fujitsu.com>
Subject: Re: [PATCH] cgroups: fix incorrect using rcu_dereference() in cgroup_subsys_state()
Date: Mon, 24 Nov 2008 12:45:49 -0800 [thread overview]
Message-ID: <6599ad830811241245v3b16853dw4c3abd0e36d40ea6@mail.gmail.com> (raw)
In-Reply-To: <49277AF7.3090000@cn.fujitsu.com>
On Fri, Nov 21, 2008 at 7:22 PM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
>> No, if you use cgroup_lock() you can do this for any task.
>> cgroup_lock() is the cgroups equivalent of the BKL, and definitely
>> prevents all task movement between groups.
>
> cgroup_exit() will defeat you.
Ah, good point. You should mention that in your description of the
locking rules. But it would be nice if we could get rid of that
restriction.
Paul
>
>>> static inline struct cgroup_subsys_state *task_subsys_state(
>>> struct task_struct *task, int subsys_id)
>>> {
>>> - return rcu_dereference(task->cgroups->subsys[subsys_id]);
>>> + /*
>>> + * ->subsys[subsys_id] are read-only data, so we do not need
>>> + * rcu_dereference() for it.
>>> + */
>>> + return rcu_dereference(task->cgroups)->subsys[subsys_id];
>>> }
>>
>> Change looks OK but I think we can lose the additional comment.
>>
>> Paul
>>
>>
>>
>
> I just remembered I had deferred Li Zefan's patch.
> (I'm also RCU developer, I had been writing CGROUP VS RCU then,
> I thought these patches should be sent together, So I deferred his patch)
>
> From: Li Zefan <lizf@cn.fujitsu.com>
> Date: Mon, 25 Aug 2008 11:05:28 +0800
> Subject: [PATCH] cgroup: fix wrong rcu_dereference()
>
> It is tsk->cgroups which is protected by RCU.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> include/linux/cgroup.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index c98dd7c..d911dc7 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -355,7 +355,7 @@ static inline struct cgroup_subsys_state *cgroup_subsys_state(
> static inline struct cgroup_subsys_state *task_subsys_state(
> struct task_struct *task, int subsys_id)
> {
> - return rcu_dereference(task->cgroups->subsys[subsys_id]);
> + return rcu_dereference(task->cgroups)->subsys[subsys_id];
> }
>
> static inline struct cgroup* task_cgroup(struct task_struct *task,
>
>
prev parent reply other threads:[~2008-11-24 20:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-21 8:49 Lai Jiangshan
2008-11-21 18:07 ` Paul Menage
2008-11-22 3:22 ` Lai Jiangshan
2008-11-24 20:45 ` Paul Menage [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=6599ad830811241245v3b16853dw4c3abd0e36d40ea6@mail.gmail.com \
--to=menage@google.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
/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
all inboxes | Powered by JetHome®