]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit - kernel/cgroup/cgroup.c
cgroup: Remove CGROUP_BUILTIN_SUBSYS_COUNT
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 13 Sep 2012 07:50:55 +0000 (09:50 +0200)
committerTejun Heo <tj@kernel.org>
Fri, 14 Sep 2012 16:57:32 +0000 (09:57 -0700)
commitbe45c900fdc2c66baad5a7703fb8136991d88aeb
treed787ad6f2d2a762c6ec581123b7325ebd62857f1
parent51e4e7faba786d33e5e33f8776c5027a1c8d6fb7
cgroup: Remove CGROUP_BUILTIN_SUBSYS_COUNT

CGROUP_BUILTIN_SUBSYS_COUNT is used as start index or stop index when
looping over the subsys array looking either at the builtin or the
module subsystems. Since all the builtin subsystems have an id which
is lower then CGROUP_BUILTIN_SUBSYS_COUNT we know that any module will
have an id larger than CGROUP_BUILTIN_SUBSYS_COUNT. In short the ids
are sorted.

We are about to change id assignment to happen only at compile time
later in this series. That means we can't rely on the above trick
since all ids will always be defined at compile time. Furthermore,
ordering the builtin subsystems and the module subsystems is not
really necessary.

So we need a different way to know which subsystem is a builtin or a
module one. We can use the subsys[]->module pointer for this. Any
place where we need to know if a subsys is module we just check for
the pointer. If it is NULL then the subsystem is a builtin one.

With this we are able to drop the CGROUP_BUILTIN_SUBSYS_COUNT
enum. Though we need to introduce a temporary placeholder so that we
don't get a compilation error when only CONFIG_CGROUP is selected and
no single controller. An empty enum definition is not valid. Later in
this series we are able to remove the placeholder again.

And with this change we get a fix for this:

kernel/cgroup.c: In function ‘cgroup_load_subsys’:
kernel/cgroup.c:4326:38: warning: array subscript is below array bounds [-Warray-bounds]

when CONFIG_CGROUP=y and no built in controller was enabled.

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Cc: Gao feng <gaofeng@cn.fujitsu.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: John Fastabend <john.r.fastabend@intel.com>
Cc: netdev@vger.kernel.org
Cc: cgroups@vger.kernel.org
include/linux/cgroup.h
kernel/cgroup.c