cgroup: add cgroup_favordynmods= command-line option
Subsystems (2)
PATCH RESEND v3 1/1 cgroup: add cgroup_favordynmods= command-line option
We have a need of using favordynmods with cgroup v1, which doesn't support changing mount flags during remount. Enabling CONFIG_CGROUP_FAVOR_DYNMODS at build-time is not an option because we want to be able to selectively enable it for certain systems.
This commit addresses this by introducing the cgroup_favordynmods= command-line option. This option works for both cgroup v1 and v2 and also allows for disabling favorynmods when the kernel built with CONFIG_CGROUP_FAVOR_DYNMODS=y.
Also, note that when cgroup_favordynmods=true favordynmods is never disabled in cgroup_destroy_root().
--- .../admin-guide/kernel-parameters.txt | 4 ++++ kernel/cgroup/cgroup.c | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)
o v3
- Handle destroy case [Michal]
- Fix type in commit log [Michal]
o v2
- Use __ro_after_init [Waiman]
Michal,
For the cgroup_destroy_root() case, I opted to keep disabling favordynmods when cgroup_favordynmods=false. The rationale is that it should allow for disabling favordynmods when/if all cgroups are gone if the user so wants.
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -580,6 +580,10 @@ named mounts. Specifying both "all" and "named" disables all v1 hierarchies. + cgroup_favordynmods= [KNL] Enable or Disable favordynmods. + Format: { "true" | "false" } + Defaults to the value of CONFIG_CGROUP_FAVOR_DYNMODS. + cgroup.memory= [KNL] Pass options to the cgroup memory controller. Format: <string> nosocket -- Disable socket memory accounting.
kernel/cgroup/cgroup.c +14 -4
@@ -207,6 +207,8 @@ static u16 have_exit_callback __read_mostly;static u16 have_release_callback__read_mostly ;static u16 have_canfork_callback__read_mostly ; +static bool have_favordynmods__ro_after_init =IS_ENABLED (CONFIG_CGROUP_FAVOR_DYNMODS ); +/* cgroup namespace for init task */ struct cgroup_namespace init_cgroup_ns = { .ns.count =REFCOUNT_INIT (2 ),
@@ -1350,7 +1352,9 @@ static void cgroup_destroy_root(struct cgroup_root *root) cgroup_root_count--; } -cgroup_favor_dynmods (root, false); +if (!have_favordynmods) +cgroup_favor_dynmods (root, false); +cgroup_exit_root_id (root);cgroup_unlock ();
@@ -2243,9 +2247,9 @@ static int cgroup_init_fs_context(struct fs_context *fc) fc->user_ns =get_user_ns (ctx->ns->user_ns); fc->global = true; -#ifdef CONFIG_CGROUP_FAVOR_DYNMODS - ctx->flags |=CGRP_ROOT_FAVOR_DYNMODS ; -#endif +if (have_favordynmods) + ctx->flags |=CGRP_ROOT_FAVOR_DYNMODS ; +return 0 ; }
@@ -6764,6 +6768,12 @@ static int __init enable_cgroup_debug(char *str) }__setup ("cgroup_debug" , enable_cgroup_debug); +static int __init cgroup_favordynmods_setup (char *str) +{ +return (kstrtobool (str, &have_favordynmods) ==0 ); +} +__setup ("cgroup_favordynmods=" , cgroup_favordynmods_setup); +/** * css_tryget_online_from_dir - get corresponding css from a cgroup dentry * @dentry: directory dentry of interest
Signature · 1 line
2.40.1
Quoted 10 lines · Luiz Capitulino
We have a need of using favordynmods with cgroup v1, which doesn't support changing mount flags during remount. Enabling
CONFIG_CGROUP_FAVOR_DYNMODSat build-time is not an option because we want to be able to selectively enable it for certain systems.This commit addresses this by introducing the cgroup_favordynmods= command-line option. This option works for both cgroup v1 and v2 and also allows for disabling favorynmods when the kernel built with
CONFIG_CGROUP_FAVOR_DYNMODS=y.
Quoted 8 lines
Also, note that when cgroup_favordynmods=true favordynmods is never disabled in
cgroup_destroy_root().Signed-off-by Luiz Capitulino <[email protected]>--- .../admin-guide/kernel-parameters.txt | 4 ++++ kernel/cgroup/cgroup.c | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)
(resend too)
Quoted 10 lines · Luiz Capitulino
We have a need of using favordynmods with cgroup v1, which doesn't support changing mount flags during remount. Enabling
CONFIG_CGROUP_FAVOR_DYNMODSat build-time is not an option because we want to be able to selectively enable it for certain systems.This commit addresses this by introducing the cgroup_favordynmods= command-line option. This option works for both cgroup v1 and v2 and also allows for disabling favorynmods when the kernel built with
CONFIG_CGROUP_FAVOR_DYNMODS=y.
Quoted 4 lines
Also, note that when cgroup_favordynmods=true favordynmods is never disabled in
cgroup_destroy_root().Signed-off-by Luiz Capitulino <[email protected]>
Applied to cgroup/for-6.7.
Thanks.
Signature · 1 line
tejun