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

From: Satoru Takeuchi
Date: Tue Mar 28 2017 - 20:03:23 EST


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

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@xxxxxxxxx>
---
kernel/cgroup/cgroup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 4885132..576b184 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -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));
--
2.7.4