Skip to content

Commit 5eab8c5

Browse files
Chen Ridonghtejun
authored andcommitted
cgroup: increase maximum subsystem count from 16 to 32
The current cgroup subsystem limit of 16 is insufficient, as the number of existing subsystems has already reached this limit. When adding a new subsystem that is not yet in the mainline kernel, building with `make allmodconfig` requires first bypassing the `BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16)` restriction to allow compilation to succeed. However, the kernel still fails to boot afterward. This patch increases the maximum number of supported cgroup subsystems from 16 to 32, providing enough room for future subsystem additions. Signed-off-by: Chen Ridong <[email protected]> Acked-by: Waiman Long <[email protected]> Tested-by: JP Kobryn <[email protected]> Acked-by: JP Kobryn <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 0ff6402 commit 5eab8c5

6 files changed

Lines changed: 39 additions & 39 deletions

File tree

include/linux/cgroup-defs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,10 @@ struct cgroup {
535535
* one which may have more subsystems enabled. Controller knobs
536536
* are made available iff it's enabled in ->subtree_control.
537537
*/
538-
u16 subtree_control;
539-
u16 subtree_ss_mask;
540-
u16 old_subtree_control;
541-
u16 old_subtree_ss_mask;
538+
u32 subtree_control;
539+
u32 subtree_ss_mask;
540+
u32 old_subtree_control;
541+
u32 old_subtree_ss_mask;
542542

543543
/* Private pointers for each registered subsystem */
544544
struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];

include/trace/events/cgroup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DECLARE_EVENT_CLASS(cgroup_root,
1616

1717
TP_STRUCT__entry(
1818
__field( int, root )
19-
__field( u16, ss_mask )
19+
__field( u32, ss_mask )
2020
__string( name, root->name )
2121
),
2222

kernel/cgroup/cgroup-internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct cgroup_fs_context {
5252
bool cpuset_clone_children;
5353
bool none; /* User explicitly requested empty subsystem */
5454
bool all_ss; /* Seen 'all' option */
55-
u16 subsys_mask; /* Selected subsystems */
55+
u32 subsys_mask; /* Selected subsystems */
5656
char *name; /* Hierarchy name */
5757
char *release_agent; /* Path for release notifications */
5858
};
@@ -146,7 +146,7 @@ struct cgroup_mgctx {
146146
struct cgroup_taskset tset;
147147

148148
/* subsystems affected by migration */
149-
u16 ss_mask;
149+
u32 ss_mask;
150150
};
151151

152152
#define CGROUP_TASKSET_INIT(tset) \
@@ -235,8 +235,8 @@ int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
235235
void cgroup_favor_dynmods(struct cgroup_root *root, bool favor);
236236
void cgroup_free_root(struct cgroup_root *root);
237237
void init_cgroup_root(struct cgroup_fs_context *ctx);
238-
int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
239-
int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
238+
int cgroup_setup_root(struct cgroup_root *root, u32 ss_mask);
239+
int rebind_subsystems(struct cgroup_root *dst_root, u32 ss_mask);
240240
int cgroup_do_get_tree(struct fs_context *fc);
241241

242242
int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp);

kernel/cgroup/cgroup-v1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define CGROUP_PIDLIST_DESTROY_DELAY HZ
2929

3030
/* Controllers blocked by the commandline in v1 */
31-
static u16 cgroup_no_v1_mask;
31+
static u32 cgroup_no_v1_mask;
3232

3333
/* disable named v1 mounts */
3434
static bool cgroup_no_v1_named;
@@ -1037,13 +1037,13 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)
10371037
static int check_cgroupfs_options(struct fs_context *fc)
10381038
{
10391039
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
1040-
u16 mask = U16_MAX;
1041-
u16 enabled = 0;
1040+
u32 mask = U32_MAX;
1041+
u32 enabled = 0;
10421042
struct cgroup_subsys *ss;
10431043
int i;
10441044

10451045
#ifdef CONFIG_CPUSETS
1046-
mask = ~((u16)1 << cpuset_cgrp_id);
1046+
mask = ~((u32)1 << cpuset_cgrp_id);
10471047
#endif
10481048
for_each_subsys(ss, i)
10491049
if (cgroup_ssid_enabled(i) && !cgroup1_ssid_disabled(i) &&
@@ -1095,7 +1095,7 @@ int cgroup1_reconfigure(struct fs_context *fc)
10951095
struct kernfs_root *kf_root = kernfs_root_from_sb(fc->root->d_sb);
10961096
struct cgroup_root *root = cgroup_root_from_kf(kf_root);
10971097
int ret = 0;
1098-
u16 added_mask, removed_mask;
1098+
u32 added_mask, removed_mask;
10991099

11001100
cgroup_lock_and_drain_offline(&cgrp_dfl_root.cgrp);
11011101

@@ -1343,7 +1343,7 @@ static int __init cgroup_no_v1(char *str)
13431343
continue;
13441344

13451345
if (!strcmp(token, "all")) {
1346-
cgroup_no_v1_mask = U16_MAX;
1346+
cgroup_no_v1_mask = U32_MAX;
13471347
continue;
13481348
}
13491349

kernel/cgroup/cgroup.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ EXPORT_SYMBOL_GPL(cgrp_dfl_root);
206206
bool cgrp_dfl_visible;
207207

208208
/* some controllers are not supported in the default hierarchy */
209-
static u16 cgrp_dfl_inhibit_ss_mask;
209+
static u32 cgrp_dfl_inhibit_ss_mask;
210210

211211
/* some controllers are implicitly enabled on the default hierarchy */
212-
static u16 cgrp_dfl_implicit_ss_mask;
212+
static u32 cgrp_dfl_implicit_ss_mask;
213213

214214
/* some controllers can be threaded on the default hierarchy */
215-
static u16 cgrp_dfl_threaded_ss_mask;
215+
static u32 cgrp_dfl_threaded_ss_mask;
216216

217217
/* The list of hierarchy roots */
218218
LIST_HEAD(cgroup_roots);
@@ -234,10 +234,10 @@ static u64 css_serial_nr_next = 1;
234234
* These bitmasks identify subsystems with specific features to avoid
235235
* having to do iterative checks repeatedly.
236236
*/
237-
static u16 have_fork_callback __read_mostly;
238-
static u16 have_exit_callback __read_mostly;
239-
static u16 have_release_callback __read_mostly;
240-
static u16 have_canfork_callback __read_mostly;
237+
static u32 have_fork_callback __read_mostly;
238+
static u32 have_exit_callback __read_mostly;
239+
static u32 have_release_callback __read_mostly;
240+
static u32 have_canfork_callback __read_mostly;
241241

242242
static bool have_favordynmods __ro_after_init = IS_ENABLED(CONFIG_CGROUP_FAVOR_DYNMODS);
243243

@@ -475,13 +475,13 @@ static bool cgroup_is_valid_domain(struct cgroup *cgrp)
475475
}
476476

477477
/* subsystems visibly enabled on a cgroup */
478-
static u16 cgroup_control(struct cgroup *cgrp)
478+
static u32 cgroup_control(struct cgroup *cgrp)
479479
{
480480
struct cgroup *parent = cgroup_parent(cgrp);
481-
u16 root_ss_mask = cgrp->root->subsys_mask;
481+
u32 root_ss_mask = cgrp->root->subsys_mask;
482482

483483
if (parent) {
484-
u16 ss_mask = parent->subtree_control;
484+
u32 ss_mask = parent->subtree_control;
485485

486486
/* threaded cgroups can only have threaded controllers */
487487
if (cgroup_is_threaded(cgrp))
@@ -496,12 +496,12 @@ static u16 cgroup_control(struct cgroup *cgrp)
496496
}
497497

498498
/* subsystems enabled on a cgroup */
499-
static u16 cgroup_ss_mask(struct cgroup *cgrp)
499+
static u32 cgroup_ss_mask(struct cgroup *cgrp)
500500
{
501501
struct cgroup *parent = cgroup_parent(cgrp);
502502

503503
if (parent) {
504-
u16 ss_mask = parent->subtree_ss_mask;
504+
u32 ss_mask = parent->subtree_ss_mask;
505505

506506
/* threaded cgroups can only have threaded controllers */
507507
if (cgroup_is_threaded(cgrp))
@@ -1636,9 +1636,9 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
16361636
* This function calculates which subsystems need to be enabled if
16371637
* @subtree_control is to be applied while restricted to @this_ss_mask.
16381638
*/
1639-
static u16 cgroup_calc_subtree_ss_mask(u16 subtree_control, u16 this_ss_mask)
1639+
static u32 cgroup_calc_subtree_ss_mask(u32 subtree_control, u32 this_ss_mask)
16401640
{
1641-
u16 cur_ss_mask = subtree_control;
1641+
u32 cur_ss_mask = subtree_control;
16421642
struct cgroup_subsys *ss;
16431643
int ssid;
16441644

@@ -1647,7 +1647,7 @@ static u16 cgroup_calc_subtree_ss_mask(u16 subtree_control, u16 this_ss_mask)
16471647
cur_ss_mask |= cgrp_dfl_implicit_ss_mask;
16481648

16491649
while (true) {
1650-
u16 new_ss_mask = cur_ss_mask;
1650+
u32 new_ss_mask = cur_ss_mask;
16511651

16521652
do_each_subsys_mask(ss, ssid, cur_ss_mask) {
16531653
new_ss_mask |= ss->depends_on;
@@ -1851,12 +1851,12 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
18511851
return ret;
18521852
}
18531853

1854-
int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
1854+
int rebind_subsystems(struct cgroup_root *dst_root, u32 ss_mask)
18551855
{
18561856
struct cgroup *dcgrp = &dst_root->cgrp;
18571857
struct cgroup_subsys *ss;
18581858
int ssid, ret;
1859-
u16 dfl_disable_ss_mask = 0;
1859+
u32 dfl_disable_ss_mask = 0;
18601860

18611861
lockdep_assert_held(&cgroup_mutex);
18621862

@@ -2152,7 +2152,7 @@ void init_cgroup_root(struct cgroup_fs_context *ctx)
21522152
set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags);
21532153
}
21542154

2155-
int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask)
2155+
int cgroup_setup_root(struct cgroup_root *root, u32 ss_mask)
21562156
{
21572157
LIST_HEAD(tmp_links);
21582158
struct cgroup *root_cgrp = &root->cgrp;
@@ -3134,7 +3134,7 @@ void cgroup_procs_write_finish(struct task_struct *task,
31343134
put_task_struct(task);
31353135
}
31363136

3137-
static void cgroup_print_ss_mask(struct seq_file *seq, u16 ss_mask)
3137+
static void cgroup_print_ss_mask(struct seq_file *seq, u32 ss_mask)
31383138
{
31393139
struct cgroup_subsys *ss;
31403140
bool printed = false;
@@ -3499,9 +3499,9 @@ static void cgroup_finalize_control(struct cgroup *cgrp, int ret)
34993499
cgroup_apply_control_disable(cgrp);
35003500
}
35013501

3502-
static int cgroup_vet_subtree_control_enable(struct cgroup *cgrp, u16 enable)
3502+
static int cgroup_vet_subtree_control_enable(struct cgroup *cgrp, u32 enable)
35033503
{
3504-
u16 domain_enable = enable & ~cgrp_dfl_threaded_ss_mask;
3504+
u32 domain_enable = enable & ~cgrp_dfl_threaded_ss_mask;
35053505

35063506
/* if nothing is getting enabled, nothing to worry about */
35073507
if (!enable)
@@ -3544,7 +3544,7 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of,
35443544
char *buf, size_t nbytes,
35453545
loff_t off)
35463546
{
3547-
u16 enable = 0, disable = 0;
3547+
u32 enable = 0, disable = 0;
35483548
struct cgroup *cgrp, *child;
35493549
struct cgroup_subsys *ss;
35503550
char *tok;
@@ -6350,7 +6350,7 @@ int __init cgroup_init(void)
63506350
struct cgroup_subsys *ss;
63516351
int ssid;
63526352

6353-
BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16);
6353+
BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 32);
63546354
BUG_ON(cgroup_init_cftypes(NULL, cgroup_base_files));
63556355
BUG_ON(cgroup_init_cftypes(NULL, cgroup_psi_files));
63566356
BUG_ON(cgroup_init_cftypes(NULL, cgroup1_base_files));

kernel/cgroup/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int cgroup_subsys_states_read(struct seq_file *seq, void *v)
230230
}
231231

232232
static void cgroup_masks_read_one(struct seq_file *seq, const char *name,
233-
u16 mask)
233+
u32 mask)
234234
{
235235
struct cgroup_subsys *ss;
236236
int ssid;

0 commit comments

Comments
 (0)