[PATCH RESEND] cgroups: fix incorrect using rcu_dereference() in cgroup_subsys_state()

Previous thread: [PATCH 2/3] tracepoint: add __rcu annotation by Lai Jiangshan on Tuesday, January 4, 2011 - 1:06 am. (1 message)

Next thread: [tip:perf/core] perf script: Finish the rename from trace to script by tip-bot for Arnaldo Carvalho de Melo on Tuesday, January 4, 2011 - 1:19 am. (1 message)
From: Lai Jiangshan
Date: Tuesday, January 4, 2011 - 1:18 am

From: Li Zefan <lizf@cn.fujitsu.com>
Date: Mon, 25 Aug 2008 11:05:28 +0800
(Original) Subject: [PATCH] cgroup: fix wrong rcu_dereference()

It is tsk->cgroups which is protected by RCU, not ->subsys[subsys_id].

laijs: updated it(the surrounding code have been changed since these two years).

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index ed4ba11..a798814 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -535,10 +535,11 @@ static inline struct cgroup_subsys_state *cgroup_subsys_state(
  * cgroup_subsys::attach() methods.
  */
 #define task_subsys_state_check(task, subsys_id, __c)			\
-	rcu_dereference_check(task->cgroups->subsys[subsys_id],		\
+	rcu_dereference_check(task->cgroups,				\
 			      rcu_read_lock_held() ||			\
 			      lockdep_is_held(&task->alloc_lock) ||	\
-			      cgroup_lock_is_held() || (__c))
+			      cgroup_lock_is_held() ||			\
+			      (__c))->subsys[subsys_id]
 
 static inline struct cgroup_subsys_state *
 task_subsys_state(struct task_struct *task, int subsys_id)
--

From: Paul E. McKenney
Date: Tuesday, January 4, 2011 - 2:23 pm

This looks plausible to me, assuming that the cgroups guys are OK with
it.

One requested change: could you please delete the rcu_read_lock_held()?
This is now implied by rcu_dereference_check().  With that:

--

Previous thread: [PATCH 2/3] tracepoint: add __rcu annotation by Lai Jiangshan on Tuesday, January 4, 2011 - 1:06 am. (1 message)

Next thread: [tip:perf/core] perf script: Finish the rename from trace to script by tip-bot for Arnaldo Carvalho de Melo on Tuesday, January 4, 2011 - 1:19 am. (1 message)