Skip to content

Commit 1bf67c8

Browse files
T.J. Mercierhtejun
authored andcommitted
cgroup/cpuset-v1: Add missing support for cpuset_v2_mode
Android has mounted the v1 cpuset controller using filesystem type "cpuset" (not "cgroup") since 2015 [1], and depends on the resulting behavior where the controller name is not added as a prefix for cgroupfs files. [2] Later, a problem was discovered where cpu hotplug onlining did not affect the cpuset/cpus files, which Android carried an out-of-tree patch to address for a while. An attempt was made to upstream this patch, but the recommendation was to use the "cpuset_v2_mode" mount option instead. [3] An effort was made to do so, but this fails with "cgroup: Unknown parameter 'cpuset_v2_mode'" because commit e1cba4b ("cgroup: Add mount flag to enable cpuset to use v2 behavior in v1 cgroup") did not update the special cased cpuset_mount(), and only the cgroup (v1) filesystem type was updated. Add parameter parsing to the cpuset filesystem type so that cpuset_v2_mode works like the cgroup filesystem type: $ mkdir /dev/cpuset $ mount -t cpuset -ocpuset_v2_mode none /dev/cpuset $ mount|grep cpuset none on /dev/cpuset type cgroup (rw,relatime,cpuset,noprefix,cpuset_v2_mode,release_agent=/sbin/cpuset_release_agent) [1] https://cs.android.com/android/_/android/platform/system/core/+/b769c8d24fd7be96f8968aa4c80b669525b930d3 [2] https://cs.android.com/android/platform/superproject/main/+/main:system/core/libprocessgroup/setup/cgroup_map_write.cpp;drc=2dac5d89a0f024a2d0cc46a80ba4ee13472f1681;l=192 [3] https://lore.kernel.org/lkml/[email protected]/T/ Fixes: e1cba4b ("cgroup: Add mount flag to enable cpuset to use v2 behavior in v1 cgroup") Signed-off-by: T.J. Mercier <[email protected]> Acked-by: Waiman Long <[email protected]> Reviewed-by: Kamalesh Babulal <[email protected]> Acked-by: Michal Koutný <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 87c259a commit 1bf67c8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

kernel/cgroup/cgroup.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,9 +2353,37 @@ static struct file_system_type cgroup2_fs_type = {
23532353
};
23542354

23552355
#ifdef CONFIG_CPUSETS_V1
2356+
enum cpuset_param {
2357+
Opt_cpuset_v2_mode,
2358+
};
2359+
2360+
static const struct fs_parameter_spec cpuset_fs_parameters[] = {
2361+
fsparam_flag ("cpuset_v2_mode", Opt_cpuset_v2_mode),
2362+
{}
2363+
};
2364+
2365+
static int cpuset_parse_param(struct fs_context *fc, struct fs_parameter *param)
2366+
{
2367+
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
2368+
struct fs_parse_result result;
2369+
int opt;
2370+
2371+
opt = fs_parse(fc, cpuset_fs_parameters, param, &result);
2372+
if (opt < 0)
2373+
return opt;
2374+
2375+
switch (opt) {
2376+
case Opt_cpuset_v2_mode:
2377+
ctx->flags |= CGRP_ROOT_CPUSET_V2_MODE;
2378+
return 0;
2379+
}
2380+
return -EINVAL;
2381+
}
2382+
23562383
static const struct fs_context_operations cpuset_fs_context_ops = {
23572384
.get_tree = cgroup1_get_tree,
23582385
.free = cgroup_fs_context_free,
2386+
.parse_param = cpuset_parse_param,
23592387
};
23602388

23612389
/*
@@ -2392,6 +2420,7 @@ static int cpuset_init_fs_context(struct fs_context *fc)
23922420
static struct file_system_type cpuset_fs_type = {
23932421
.name = "cpuset",
23942422
.init_fs_context = cpuset_init_fs_context,
2423+
.parameters = cpuset_fs_parameters,
23952424
.fs_flags = FS_USERNS_MOUNT,
23962425
};
23972426
#endif

0 commit comments

Comments
 (0)