From: Chen Wandun chenwandun@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8QUNW
-------------------------------
Add CONFIG_PSI_CGROUP_V1 to separate feature of psi under cgroup v1 from baseline.
Signed-off-by: Chen Wandun chenwandun@huawei.com Conflicts: kernel/cgroup/cgroup.c kernel/sched/cpuacct.c kernel/sched/psi.c include/linux/psi.h Signed-off-by: Lu Jialin lujialin4@huawei.com --- include/linux/psi.h | 2 ++ init/Kconfig | 10 ++++++++++ kernel/cgroup/cgroup.c | 2 ++ kernel/sched/psi.c | 4 ++++ 4 files changed, 18 insertions(+)
diff --git a/include/linux/psi.h b/include/linux/psi.h index 49afe8d1cde6..9e5d49cf62d5 100644 --- a/include/linux/psi.h +++ b/include/linux/psi.h @@ -15,7 +15,9 @@ struct css_set; #ifdef CONFIG_PSI
extern struct static_key_false psi_disabled; +#ifdef CONFIG_PSI_CGROUP_V1 extern struct static_key_true psi_v1_disabled; +#endif extern struct psi_group psi_system;
void psi_init(void); diff --git a/init/Kconfig b/init/Kconfig index 2ee1384c4f81..0a6810db5f93 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -667,6 +667,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 7eef310a96a1..3942e99c4c4a 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3902,6 +3902,7 @@ bool cgroup_psi_enabled(void) return (cgroup_feature_disable_mask & (1 << OPT_FEATURE_PRESSURE)) == 0; }
+#ifdef CONFIG_PSI_CGROUP_V1 struct cftype cgroup_v1_psi_files[] = { { .name = "io.pressure", @@ -3939,6 +3940,7 @@ struct cftype cgroup_v1_psi_files[] = { #endif { } /* terminate */ }; +#endif #else /* CONFIG_PSI */ bool cgroup_psi_enabled(void) { diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 7aec8161b693..600ee0d2f42d 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -888,6 +888,9 @@ static inline struct psi_group *task_psi_group(struct task_struct *task) { #ifdef CONFIG_CGROUPS if (static_branch_likely(&psi_cgroups_enabled)) { +#ifndef CONFIG_PSI_CGROUP_V1 + return cgroup_psi(task_dfl_cgroup(task)); +#endif #ifdef CONFIG_CGORUP_CPUACCT if (!cgroup_subsys_on_dfl(cpuacct_cgrp_subsys)) { if (static_branch_likely(&psi_v1_disabled)) @@ -1106,6 +1109,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