Skip to contentSkip to conversation

blk-cgroup: Call cgroup_path only under cgroup lock

PATCH In review Sasha Levin 2 participants 4 messages Mar 12, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-cgroup: Call cgroup_path only under cgroup lock

Since we can't keep rcu read lock during blkg_alloc(), we currently call cgroup_path() without any locks at all.

This patch adds cgroup locking before calling cgroup_path.

This also fixes a lockdep warning on boot.

---
 block/blk-cgroup.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
block/blk-cgroup.c +2 -0
index cb6b176..b5f539c 100644
@@ -508,7 +508,9 @@ static struct blkio_group *blkg_alloc(struct blkio_cgroup *blkcg,
 	INIT_LIST_HEAD(&blkg->q_node);
 	blkg->blkcg = blkcg;
 	blkg->refcnt = 1;
+	cgroup_lock();
 	cgroup_path(blkcg->css.cgroup, blkg->path, sizeof(blkg->path));
+	cgroup_unlock();
 
 	for (i = 0; i < BLKIO_NR_POLICIES; i++) {
 		struct blkio_policy_type *pol = blkio_policy[i];
Signature · 1 line
1.7.8.4
maintainer
#1 lore raw

Hello, Sasha.

Quoted 8 lines · Sasha Levin

Since we can't keep rcu read lock during blkg_alloc(), we currently call cgroup_path() without any locks at all.

This patch adds cgroup locking before calling cgroup_path.

This also fixes a lockdep warning on boot.

Which branch is this against? There's already pending stat update patch from Vivek which fix this problem along with the percpu allocation problem.

Thanks.

Signature · 1 line
tejun
#2 lore raw
Quoted 10 lines · Tejun Heo

Hello, Sasha.

Quoted 7 lines · Sasha Levin

Since we can't keep rcu read lock during blkg_alloc(), we currently call cgroup_path() without any locks at all.

This patch adds cgroup locking before calling cgroup_path.

This also fixes a lockdep warning on boot.

Quoted 7 lines
Quoted 1 line

Which branch is this against?  There's already pending stat update patch from Vivek which fix this problem along with the percpu allocation problem.

Thanks.

I've fixed it for linux-next.

maintainer
#3 lore raw
Quoted 13 lines · Sasha Levin
Quoted 12 lines · Tejun Heo

Hello, Sasha.

Quoted 8 lines · Sasha Levin

Since we can't keep rcu read lock during blkg_alloc(), we currently call cgroup_path() without any locks at all.

This patch adds cgroup locking before calling cgroup_path.

This also fixes a lockdep warning on boot.

Quoted 7 lines
Quoted 5 lines

Which branch is this against?  There's already pending stat update patch from Vivek which fix this problem along with the percpu allocation problem.

Thanks.

I've fixed it for linux-next.

Jens, the pending stats patchset should fix this problem too. Can you please put them on top of other blkcg updates?

Thanks.

Signature · 1 line
tejun