[Devel] [PATCH RH7] mm/memcg: do not save call stacks of css_get/put by default

Evgenii Shatokhin eshatokhin at virtuozzo.com
Fri Jul 2 19:11:46 MSK 2021


Commit f0c5834e75fc ("mm/memcg: save css_get/put stacks") left saving of
call stacks for css_get/put operations enabled by default. As it turned
out, it caused about 10% performance loss in the use cases where
such operations with memcg happened often (see PSBM-131085). If such css
debugging was turned off, the performance regression disappeared.

Let us keep saving of stacks for css operations off by default. If
needed, it can be enabled in runtime:
  echo 1 > /sys/kernel/debug/css_stacks

While at it, I replaced "no_css_stacks" boot option with "css_stacks=",
which accepts 0/1/on/off/... (see the description of kstrtobool()) and
allows the user to enable or disable this debugging feature at boot
time. This way, even if we decide to flip the defaults again in the
future, the boot option would still be usable.

https://jira.sw.ru/browse/PSBM-131085
Signed-off-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
---
 kernel/cgroup.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b6408e60619b..9d360a080990 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4512,7 +4512,7 @@ static int css_stacks_set(void *data, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(css_stacks_fops,
 		css_stacks_get, css_stacks_set, "%llu\n");
 
-int setup_css_stacks_cmd = 1;
+bool setup_css_stacks_cmd;
 static int __init css_stacks_debugfs(void)
 {
 	void *ret;
@@ -4529,10 +4529,9 @@ late_initcall(css_stacks_debugfs);
 
 static int __init setup_css_stacks(char *str)
 {
-	setup_css_stacks_cmd = 0;
-	return 1;
+	return (kstrtobool(str, &setup_css_stacks_cmd) == 0);
 }
-__setup("no_css_stacks", setup_css_stacks);
+__setup("css_stacks=", setup_css_stacks);
 #endif
 
 static void init_cgroup_css(struct cgroup_subsys_state *css,
-- 
2.29.0



More information about the Devel mailing list