public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATH v2] cgroup: add cgroup_favordynmods= command-line option
@ 2023-09-06  0:57 Luiz Capitulino
       [not found] ` <20230906005712.66461-1-luizcap-vV1OtcyAfmbQT0dZR+AlfA@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Luiz Capitulino @ 2023-09-06  0:57 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
	hannes-druUgvl0LCNAfugRpC6u6w, cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	longman-H+wXaHxf7aLQT0dZR+AlfA
  Cc: lcapitulino-Re5JQEeQqe8AvxtiuMwx3w, Luiz Capitulino

We have a need of using favordynmods with cgroup v1, which doesn't support
changing mount flags during remount. Enabling CONFIG_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_FAVOR_DYNMODS=y.

Signed-off-by: Luiz Capitulino <luizcap-vV1OtcyAfmbQT0dZR+AlfA@public.gmane.org>
---
 Documentation/admin-guide/kernel-parameters.txt |  4 ++++
 kernel/cgroup/cgroup.c                          | 14 +++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

o v2
 - Use __ro_after_init [Waiman]

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0a1731a0f0ef..8b744d39d393 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -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.
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 1fb7f562289d..2b7d74304606 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -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),
@@ -2243,9 +2245,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 +6766,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
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-09-19 13:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-06  0:57 [PATH v2] cgroup: add cgroup_favordynmods= command-line option Luiz Capitulino
     [not found] ` <20230906005712.66461-1-luizcap-vV1OtcyAfmbQT0dZR+AlfA@public.gmane.org>
2023-09-06  1:53   ` Waiman Long
2023-09-06  6:58   ` Kamalesh Babulal
2023-09-06 12:59     ` Waiman Long
2023-09-07  9:51       ` [External] : " Kamalesh Babulal
2023-09-07 18:47         ` Luiz Capitulino
     [not found]           ` <e7675405-c910-340e-0679-0271dff76722-vV1OtcyAfmbQT0dZR+AlfA@public.gmane.org>
2023-09-08  7:04             ` Kamalesh Babulal
2023-09-07 15:06 ` Michal Koutný
2023-09-07 15:16   ` Luiz Capitulino
2023-09-07 15:57     ` Michal Koutný
2023-09-07 18:57       ` Luiz Capitulino
     [not found] ` <29bdb453-c6e3-a047-1f27-e9656da92301@amazon.com>
2023-09-18 17:47   ` Tejun Heo
     [not found]     ` <ZQiNIWQe7spOwjil-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-09-19 11:00       ` Michal Koutný
2023-09-19 13:42         ` Luiz Capitulino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox