Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 8, but
MAX_LOCKDEP_SUBCLASSES is 8.

This patch uses different lockdep keys for different subsystems.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Paul Menage <menage@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Li Zefan and committed by
Linus Torvalds
cfebe563 01c4a428

+3 -1
+1
include/linux/cgroup.h
··· 378 378 * - initiating hotplug events 379 379 */ 380 380 struct mutex hierarchy_mutex; 381 + struct lock_class_key subsys_key; 381 382 382 383 /* 383 384 * Link to parent, and list entry in parent's children.
+2 -1
kernel/cgroup.c
··· 2351 2351 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 2352 2352 struct cgroup_subsys *ss = subsys[i]; 2353 2353 if (ss->root == root) 2354 - mutex_lock_nested(&ss->hierarchy_mutex, i); 2354 + mutex_lock(&ss->hierarchy_mutex); 2355 2355 } 2356 2356 } 2357 2357 ··· 2637 2637 BUG_ON(!list_empty(&init_task.tasks)); 2638 2638 2639 2639 mutex_init(&ss->hierarchy_mutex); 2640 + lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key); 2640 2641 ss->active = 1; 2641 2642 } 2642 2643