From: Chen Wandun chenwandun@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8BCV4
-------------------------------
Add CONFIG_PSI_CGROUP_V1 to separate feature of psi under cgroup v1 from baseline.
Signed-off-by: Chen Wandun chenwandun@huawei.com Signed-off-by: Lu Jialin lujialin4@huawei.com --- include/linux/psi.h | 2 ++ init/Kconfig | 10 ++++++++++ kernel/cgroup/cgroup.c | 3 +++ kernel/sched/cpuacct.c | 2 +- kernel/sched/psi.c | 22 ++++++++++++++-------- 5 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/include/linux/psi.h b/include/linux/psi.h index c4bb670225ee..40cfbf0bf831 100644 --- a/include/linux/psi.h +++ b/include/linux/psi.h @@ -14,7 +14,9 @@ struct css_set; extern struct static_key_false psi_disabled; extern struct psi_group psi_system;
+#ifdef CONFIG_PSI_CGROUP_V1 extern struct static_key_true psi_v1_disabled; +#endif
void psi_init(void);
diff --git a/init/Kconfig b/init/Kconfig index bb9063807556..c668fb4933f6 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -653,6 +653,16 @@ config PSI_DEFAULT_DISABLED
Say N if unsure.
+config PSI_CGROUP_V1 + bool "Support PSI under cgroup v1" + default n + depends on PSI + help + If set, pressure stall information tracking will be used + for cgroup v1 other than v2. + + Say N if unsure. + endmenu # "CPU/Task time and stats accounting"
config CPU_ISOLATION diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 55b336656fc9..5588c5a3804d 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3783,6 +3783,7 @@ static void cgroup_pressure_release(struct kernfs_open_file *of) psi_trigger_destroy(ctx->psi.trigger); }
+#ifdef CONFIG_PSI_CGROUP_V1 struct cftype cgroup_v1_psi_files[] = { { .name = "io.pressure", @@ -3820,6 +3821,8 @@ struct cftype cgroup_v1_psi_files[] = { #endif { } /* terminate */ }; +#endif + #endif /* CONFIG_PSI */
static int cgroup_freeze_show(struct seq_file *seq, void *v) diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 1fa89f338e51..7a7a0dec8c4e 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -375,7 +375,7 @@ struct cgroup_subsys cpuacct_cgrp_subsys = { .early_init = true, };
-#ifdef CONFIG_PSI +#ifdef CONFIG_PSI_CGROUP_V1
static bool psi_v1_enable; static int __init setup_psi_v1(char *str) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 3623b113b8f0..9b59f1b5d6cf 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -156,7 +156,10 @@ static int psi_bug __read_mostly;
DEFINE_STATIC_KEY_FALSE(psi_disabled); + +#ifdef CONFIG_PSI_CGROUP_V1 DEFINE_STATIC_KEY_TRUE(psi_v1_disabled); +#endif
#ifdef CONFIG_PSI_DEFAULT_DISABLED static bool psi_enable; @@ -785,21 +788,23 @@ static struct psi_group *iterate_groups(struct task_struct *task, void **iter) struct cgroup *cgroup = NULL;
if (!*iter) { - if (static_branch_likely(&psi_v1_disabled)) - cgroup = task->cgroups->dfl_cgrp; - else { +#ifndef CONFIG_PSI_CGROUP_V1 + cgroup = task->cgroups->dfl_cgrp; +#else #ifdef CONFIG_CGROUP_CPUACCT - if (!cgroup_subsys_on_dfl(cpuacct_cgrp_subsys)) { + if (!cgroup_subsys_on_dfl(cpuacct_cgrp_subsys)) { + if (!static_branch_likely(&psi_v1_disabled)) { rcu_read_lock(); cgroup = task_cgroup(task, cpuacct_cgrp_id); rcu_read_unlock(); - } else { - cgroup = task->cgroups->dfl_cgrp; } + } else { + cgroup = task->cgroups->dfl_cgrp; + } #else - cgroup = NULL; + cgroup = NULL; +#endif #endif - } } else if (*iter == &psi_system) return NULL; else @@ -1006,6 +1011,7 @@ void psi_memstall_leave(unsigned long *flags) return;
trace_psi_memstall_leave(_RET_IP_); + /* * in_memstall clearing & accounting needs to be atomic wrt * changes to the task's scheduling state, otherwise we could