netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cls_cgroup: Fix rcu lockdep warning
@ 2010-09-02  6:30 Li Zefan
  2010-09-02 10:38 ` Peter Zijlstra
  2010-09-03  4:52 ` Herbert Xu
  0 siblings, 2 replies; 6+ messages in thread
From: Li Zefan @ 2010-09-02  6:30 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Dave Jones, netdev, LKML

Calling task_subsys_state() without holding rcu_read_lock or
cgroup_mutex can cause lockdep warning.

Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/net/cls_cgroup.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index dd1fdb8..a4dc5b0 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -27,11 +27,17 @@ struct cgroup_cls_state
 #ifdef CONFIG_NET_CLS_CGROUP
 static inline u32 task_cls_classid(struct task_struct *p)
 {
+	int classid;
+
 	if (in_interrupt())
 		return 0;
 
-	return container_of(task_subsys_state(p, net_cls_subsys_id),
-			    struct cgroup_cls_state, css)->classid;
+	rcu_read_lock();
+	classid = container_of(task_subsys_state(p, net_cls_subsys_id),
+			       struct cgroup_cls_state, css)->classid;
+	rcu_read_unlock();
+
+	return classid;
 }
 #else
 extern int net_cls_subsys_id;
-- 
1.6.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-03  4:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-02  6:30 [PATCH] cls_cgroup: Fix rcu lockdep warning Li Zefan
2010-09-02 10:38 ` Peter Zijlstra
2010-09-02 17:05   ` David Miller
2010-09-02 17:16     ` Paul E. McKenney
2010-09-03  1:10   ` Li Zefan
2010-09-03  4:52 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).