Skip to contentSkip to conversation

cgroup: change the limit of CGROUP_SUBSYS_COUNT depending on the size of the corresponding bitmasks

PATCH New Satoru Takeuchi 1 participant 1 message Mar 29, 2017 cgroup

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup: change the limit of CGROUP_SUBSYS_COUNT depending on the size of the corresponding bitmasks

The limit of CGROUP_SUBSYS_COUNT is hardcoded to 16. This value comes from the size of the corresponding bitmasks, u16. It's better to change this limit depending on the size of the corresponding bitmasks because of the following reasons.

- to avoid setting the wrong limit when the size of the corresponding bitmasks are changed
- to make the meaning of this limit clear

---
 kernel/cgroup/cgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/cgroup/cgroup.c +2 -1
index 4885132..576b184 100644
@@ -4490,7 +4490,8 @@ int __init cgroup_init(void)
 	struct cgroup_subsys *ss;
 	int ssid;
 
-	BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16);
+	BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > (sizeof(cgroup_disable_mask) * __CHAR_BIT__));
+
 	BUG_ON(percpu_init_rwsem(&cgroup_threadgroup_rwsem));
 	BUG_ON(cgroup_init_cftypes(NULL, cgroup_base_files));
 	BUG_ON(cgroup_init_cftypes(NULL, cgroup1_base_files));
Signature · 1 line
2.7.4