Skip to contentSkip to conversation

cgroup: Check task_lock in task_subsys_state()

PATCH In review Li Zefan 3 participants 3 messages Apr 23, 2010 cgroup

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 cgroup: Check task_lock in task_subsys_state()

task_subsys_state() is safe under task_lock(). See Documentation/cgroups/cgroups.txt for locking rule.

This fixes an RCU warning when resume from suspend. The warning comes from freezer cgroup in cgroup_freezing_or_frozen().

---

I'm not sure which is preferable - access ->alloc_lock directly like this patch or add task_lock_is_held() in sched.h

---
 include/linux/cgroup.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/cgroup.h +1 -0
index b8ad1ea..8f78073 100644
@@ -530,6 +530,7 @@ static inline struct cgroup_subsys_state *task_subsys_state(
 {
 	return rcu_dereference_check(task->cgroups->subsys[subsys_id],
 				     rcu_read_lock_held() ||
+				     lockdep_is_held(&task->alloc_lock) ||
 				     cgroup_lock_is_held());
 }
 
Signature · 1 line
1.6.3
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Li Zefan

task_subsys_state() is safe under task_lock(). See Documentation/cgroups/cgroups.txt for locking rule.

This fixes an RCU warning when resume from suspend. The warning comes from freezer cgroup in cgroup_freezing_or_frozen().

Quoted 23 lines

---

I'm not sure which is preferable - access ->alloc_lock directly like this patch or add task_lock_is_held() in sched.h

---
 include/linux/cgroup.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/cgroup.h +1 -0
index b8ad1ea..8f78073 100644
@@ -530,6 +530,7 @@ static inline struct cgroup_subsys_state *task_subsys_state(
 {
 	return rcu_dereference_check(task->cgroups->subsys[subsys_id],
 				     rcu_read_lock_held() ||
+				     lockdep_is_held(&task->alloc_lock) ||
 				     cgroup_lock_is_held());
 }
 
Signature · 1 line
1.6.3
#2 lore raw
In reply to Li Zefan
Quoted 11 lines · Li Zefan

task_subsys_state() is safe under task_lock(). See Documentation/cgroups/cgroups.txt for locking rule.

This fixes an RCU warning when resume from suspend. The warning comes from freezer cgroup in cgroup_freezing_or_frozen().

---

I'm not sure which is preferable - access ->alloc_lock directly like this patch or add task_lock_is_held() in sched.h

This is for the maintainers to decide, either way works from my viewpoint.

I have queued it as is with Matt's Acked-by, and am testing it. Thank you!!!

Thanx, Paul

Quoted 18 lines
---
 include/linux/cgroup.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/cgroup.h +1 -0
index b8ad1ea..8f78073 100644
@@ -530,6 +530,7 @@ static inline struct cgroup_subsys_state *task_subsys_state(
 {
 	return rcu_dereference_check(task->cgroups->subsys[subsys_id],
 				     rcu_read_lock_held() ||
+				     lockdep_is_held(&task->alloc_lock) ||
 				     cgroup_lock_is_held());
 }
 
Signature · 1 line
1.6.3