Skip to contentSkip to conversation

cgroups: fix lockdep subclasses overflow

PATCH In review Li Zefan 4 participants 5 messages Feb 4, 2009 1 message not in the archive cgroup

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 cgroups: fix lockdep subclasses overflow

I enabled all cgroup subsystems when compiling kernel, and then:

 # mount -t cgroup -o net_cls xxx /mnt
 # mkdir /mnt/0

This showed up immediately:

 BUG: MAX_LOCKDEP_SUBCLASSES too low!
 turning off the locking correctness validator.

It's caused by the cgroup hierarchy lock:

	for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
		struct cgroup_subsys *ss = subsys[i];
		if (ss->root == root)
			mutex_lock_nested(&ss->hierarchy_mutex, i);
	}

Now we have 9 cgroup subsystems, and the above 'i' for net_cls is 9, but MAX_LOCKDEP_SUBCLASSES is 8.

This patch uses different lockdep keys for different subsystems.

---
 include/linux/cgroup.h |    1 +
 kernel/cgroup.c        |    3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)
include/linux/cgroup.h +1 -0
index e4e8e11..499900d 100644
@@ -378,6 +378,7 @@ struct cgroup_subsys {
 	 * - initiating hotplug events
 	 */
 	struct mutex hierarchy_mutex;
+	struct lock_class_key subsys_key;
 
 	/*
 	 * Link to parent, and list entry in parent's children.
kernel/cgroup.c +2 -1
index 5a54ff4..e14db9c 100644
@@ -2351,7 +2351,7 @@ static void cgroup_lock_hierarchy(struct cgroupfs_root *root)
 	for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
 		struct cgroup_subsys *ss = subsys[i];
 		if (ss->root == root)
-			mutex_lock_nested(&ss->hierarchy_mutex, i);
+			mutex_lock(&ss->hierarchy_mutex);
 	}
 }
 
@@ -2637,6 +2637,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
 	BUG_ON(!list_empty(&init_task.tasks));
 
 	mutex_init(&ss->hierarchy_mutex);
+	lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
 	ss->active = 1;
 }
 
Signature · 1 line
1.5.4.rc3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 8 lines · Li Zefan

I enabled all cgroup subsystems when compiling kernel, and then:

 # mount -t cgroup -o net_cls xxx /mnt
 # mkdir /mnt/0

This showed up immediately:

 BUG: MAX_LOCKDEP_SUBCLASSES too low!
 turning off the locking correctness validator.
Quoted 8 lines

It's caused by the cgroup hierarchy lock:

	for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
		struct cgroup_subsys *ss = subsys[i];
		if (ss->root == root)
			mutex_lock_nested(&ss->hierarchy_mutex, i);
	}

Now we have 9 cgroup subsystems, and the above 'i' for net_cls is 9, but

sorry, a typo here: the above 'i' for net_cls is 8.

Quoted 6 lines

MAX_LOCKDEP_SUBCLASSES is 8.

This patch uses different lockdep keys for different subsystems.

---

Acked-by
#3 lore raw
In reply to a message not in the archive
Quoted 4 lines · Li Zefan

This patch uses different lockdep keys for different subsystems.

Looks good, thanks.

Paul

Quoted 44 lines
---
 include/linux/cgroup.h |    1 +
 kernel/cgroup.c        |    3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)
include/linux/cgroup.h +1 -0
index e4e8e11..499900d 100644
@@ -378,6 +378,7 @@ struct cgroup_subsys {
        * - initiating hotplug events
        */
       struct mutex hierarchy_mutex;
+       struct lock_class_key subsys_key;
 
       /*
        * Link to parent, and list entry in parent's children.
kernel/cgroup.c +2 -2
index 5a54ff4..e14db9c 100644
@@ -2351,7 +2351,7 @@ static void cgroup_lock_hierarchy(struct cgroupfs_root *root)
       for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
               struct cgroup_subsys *ss = subsys[i];
               if (ss->root == root)
-                       mutex_lock_nested(&ss->hierarchy_mutex, i);
+                       mutex_lock(&ss->hierarchy_mutex);
       }
 }
 
@@ -2637,6 +2637,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
       BUG_ON(!list_empty(&init_task.tasks));
 
       mutex_init(&ss->hierarchy_mutex);
+       lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
       ss->active = 1;
 }
 
--

1.5.4.rc3

author
#4 lore raw
In reply to Li Zefan
Quoted 8 lines · Li Zefan

I enabled all cgroup subsystems when compiling kernel, and then:

 # mount -t cgroup -o net_cls xxx /mnt
 # mkdir /mnt/0

This showed up immediately:

 BUG: MAX_LOCKDEP_SUBCLASSES too low!
 turning off the locking correctness validator.
Quoted 8 lines

It's caused by the cgroup hierarchy lock:

	for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
		struct cgroup_subsys *ss = subsys[i];
		if (ss->root == root)
			mutex_lock_nested(&ss->hierarchy_mutex, i);
	}

Now we have 9 cgroup subsystems, and the above 'i' for net_cls is 9, but

sorry, a typo here: the above 'i' for net_cls is 8.

Quoted 6 lines

MAX_LOCKDEP_SUBCLASSES is 8.

This patch uses different lockdep keys for different subsystems.

---

Acked-by on v1 1/1
#5 lore raw
In reply to Li Zefan
Quoted 4 lines · Li Zefan

This patch uses different lockdep keys for different subsystems.

Looks good, thanks.

Paul

Quoted 44 lines
---
 include/linux/cgroup.h |    1 +
 kernel/cgroup.c        |    3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)
include/linux/cgroup.h +1 -0
index e4e8e11..499900d 100644
@@ -378,6 +378,7 @@ struct cgroup_subsys {
        * - initiating hotplug events
        */
       struct mutex hierarchy_mutex;
+       struct lock_class_key subsys_key;
 
       /*
        * Link to parent, and list entry in parent's children.
kernel/cgroup.c +2 -2
index 5a54ff4..e14db9c 100644
@@ -2351,7 +2351,7 @@ static void cgroup_lock_hierarchy(struct cgroupfs_root *root)
       for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
               struct cgroup_subsys *ss = subsys[i];
               if (ss->root == root)
-                       mutex_lock_nested(&ss->hierarchy_mutex, i);
+                       mutex_lock(&ss->hierarchy_mutex);
       }
 }
 
@@ -2637,6 +2637,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
       BUG_ON(!list_empty(&init_task.tasks));
 
       mutex_init(&ss->hierarchy_mutex);
+       lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
       ss->active = 1;
 }
 
--

1.5.4.rc3