ANDROID: make per-cgroup PSI tracking configurable
With cgroup v2 hierarchy enabled PSI accounts stalls for each cgroup
separately and aggregates at each level of the hierarchy. That causes
additional overhead since psi_avgs_work would be called for each
cgroup in the hierarchy.
In Android we use PSI only at the system level, therefore this overhead
can be avoided.
Introduce CONFIG_PSI_PER_CGROUP_ACCT that controls per-cgroup PSI
tracking and is disabled by default.
Bug: 178872719
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I70a418aba76b46a27eb9e66080434aa870496384
diff --git a/init/Kconfig b/init/Kconfig
index 9603a58..228a0a4 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -636,6 +636,21 @@
Say N if unsure.
+config PSI_PER_CGROUP_ACCT
+ bool "Enable per-cgroup pressure stall information tracking"
+ default n
+ depends on PSI
+ depends on CGROUPS
+ help
+ If set, pressure stall information will be tracked for each
+ individual cgroup. Otherwise, pressure stall information will
+ be tracked only at the system level under /proc/pressure/.
+
+ This feature generates overhead that depends on the number of
+ cgroups in the cgroup v2 hierarchy.
+
+ Say N if unsure.
+
endmenu # "CPU/Task time and stats accounting"
config CPU_ISOLATION
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 967732c..fcc4603 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -743,7 +743,7 @@
static struct psi_group *iterate_groups(struct task_struct *task, void **iter)
{
-#ifdef CONFIG_CGROUPS
+#if defined CONFIG_CGROUPS && defined CONFIG_PSI_PER_CGROUP_ACCT
struct cgroup *cgroup = NULL;
if (!*iter)