From: Tejun Heo Date: Thu, 3 Mar 2016 14:58:01 +0000 (-0500) Subject: cgroup: allocate 2x cgrp_cset_links when setting up a new root X-Git-Tag: v4.6-rc1~92^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04313591ae487da8b5781a0d8d444073a3fdee0d;p=platform%2Fkernel%2Flinux-exynos.git cgroup: allocate 2x cgrp_cset_links when setting up a new root During prep, cgroup_setup_root() allocates cgrp_cset_links matching the number of existing css_sets to later link the new root. This is fine for now as the only operation which can happen inbetween is rebind_subsystems() and rebinding of empty subsystems doesn't create new css_sets. However, while not yet allowed, with the recent reimplementation, rebind_subsystems() can rebind subsystems with descendant csses and thus can create new css_sets. This patch makes cgroup_setup_root() allocate 2x of the existing css_sets so that later use of live subsystem rebinding doesn't blow up. Signed-off-by: Tejun Heo Acked-by: Zefan Li --- diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 58e02e9..40ed329 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -1915,10 +1915,11 @@ static int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask) /* * We're accessing css_set_count without locking css_set_lock here, * but that's OK - it can only be increased by someone holding - * cgroup_lock, and that's us. The worst that can happen is that we - * have some link structures left over + * cgroup_lock, and that's us. Later rebinding may disable + * controllers on the default hierarchy and thus create new csets, + * which can't be more than the existing ones. Allocate 2x. */ - ret = allocate_cgrp_cset_links(css_set_count, &tmp_links); + ret = allocate_cgrp_cset_links(2 * css_set_count, &tmp_links); if (ret) goto cancel_ref;