cgroup: disable controllers at parse time

This patch effectively reverts the commit a3e72739b7a7 ("cgroup: fix
too early usage of static_branch_disable()"). The commit 6041186a3258
("init: initialize jump labels before command line option parsing") has
moved the jump_label_init() before parse_args() which has made the
commit a3e72739b7a7 unnecessary. On the other hand there are
consequences of disabling the controllers later as there are subsystems
doing the controller checks for different decisions. One such incident
is reported [1] regarding the memory controller and its impact on memory
reclaim code.

[1] https://lore.kernel.org/linux-mm/921e53f3-4b13-aab8-4a9e-e83ff15371e4@nec.com

Signed-off-by: Shakeel Butt <shakeelb@google.com>
Reported-by: NOMURA JUNICHI(野村 淳一) <junichi.nomura@nec.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Tested-by: Jun'ichi Nomura <junichi.nomura@nec.com>

authored by Shakeel Butt and committed by Tejun Heo 45e1ba40 c3d0e3fd

+5 -8
+5 -8
kernel/cgroup/cgroup.c
··· 5634 return 0; 5635 } 5636 5637 - static u16 cgroup_disable_mask __initdata; 5638 - 5639 /** 5640 * cgroup_init - cgroup initialization 5641 * ··· 5692 * disabled flag and cftype registration needs kmalloc, 5693 * both of which aren't available during early_init. 5694 */ 5695 - if (cgroup_disable_mask & (1 << ssid)) { 5696 - static_branch_disable(cgroup_subsys_enabled_key[ssid]); 5697 - printk(KERN_INFO "Disabling %s control group subsystem\n", 5698 - ss->name); 5699 continue; 5700 - } 5701 5702 if (cgroup1_ssid_disabled(ssid)) 5703 printk(KERN_INFO "Disabling %s control group subsystem in v1 mounts\n", ··· 6208 if (strcmp(token, ss->name) && 6209 strcmp(token, ss->legacy_name)) 6210 continue; 6211 - cgroup_disable_mask |= 1 << i; 6212 } 6213 } 6214 return 1;
··· 5634 return 0; 5635 } 5636 5637 /** 5638 * cgroup_init - cgroup initialization 5639 * ··· 5694 * disabled flag and cftype registration needs kmalloc, 5695 * both of which aren't available during early_init. 5696 */ 5697 + if (!cgroup_ssid_enabled(ssid)) 5698 continue; 5699 5700 if (cgroup1_ssid_disabled(ssid)) 5701 printk(KERN_INFO "Disabling %s control group subsystem in v1 mounts\n", ··· 6214 if (strcmp(token, ss->name) && 6215 strcmp(token, ss->legacy_name)) 6216 continue; 6217 + 6218 + static_branch_disable(cgroup_subsys_enabled_key[i]); 6219 + pr_info("Disabling %s control group subsystem\n", 6220 + ss->name); 6221 } 6222 } 6223 return 1;