diff --git a/init/Kconfig b/init/Kconfig index d674fd81b171cebf3e90b1e9f4e1a61330c0fe17..5eda763822a1582c1ed41e7444008fddd3fe1d52 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -532,6 +532,16 @@ config PSI_DEFAULT_DISABLED Say N if unsure. +config PSI_CGROUP_V1 + bool "Support PSI under cgroup v1" + default Y + 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 c7e066431eb8946282a1ee9d5fd9fd89a5544bf8..474a23b1582209c9fd8110c7e6bd3adac4a45ead 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3518,6 +3518,34 @@ static void cgroup_pressure_release(struct kernfs_open_file *of) { psi_trigger_replace(&of->priv, NULL); } + +struct cftype cgroup_v1_psi_files[] = { + { + .name = "io.pressure", + .flags = CFTYPE_NO_PREFIX, + .seq_show = cgroup_io_pressure_show, + .write = cgroup_io_pressure_write, + .poll = cgroup_pressure_poll, + .release = cgroup_pressure_release, + }, + { + .name = "memory.pressure", + .flags = CFTYPE_NO_PREFIX, + .seq_show = cgroup_memory_pressure_show, + .write = cgroup_memory_pressure_write, + .poll = cgroup_pressure_poll, + .release = cgroup_pressure_release, + }, + { + .name = "cpu.pressure", + .flags = CFTYPE_NO_PREFIX, + .seq_show = cgroup_cpu_pressure_show, + .write = cgroup_cpu_pressure_write, + .poll = cgroup_pressure_poll, + .release = cgroup_pressure_release, + }, + { } /* terminate */ +}; #endif /* CONFIG_PSI */ static int cgroup_file_open(struct kernfs_open_file *of) diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 9fbb103834345fcc5a07c4a04f1a586d3bfa48b7..59f515ac11b54d88de73fd1709717cafe2ee1630 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -373,3 +373,13 @@ struct cgroup_subsys cpuacct_cgrp_subsys = { .legacy_cftypes = files, .early_init = true, }; + +#ifdef CONFIG_PSI +static int __init cgroup_v1_psi_init(void) +{ + cgroup_add_legacy_cftypes(&cpuacct_cgrp_subsys, cgroup_v1_psi_files); + return 0; +} + +late_initcall_sync(cgroup_v1_psi_init); +#endif diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 517e3719027e619e5c7b565d1de9294dfffb5a3c..677ed6516066d33e686340defdb410292684599c 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -725,7 +725,11 @@ static struct psi_group *iterate_groups(struct task_struct *task, void **iter) struct cgroup *cgroup = NULL; if (!*iter) +#ifdef CONFIG_PSI_CGROUP_V1 + cgroup = task_cgroup(task, cpuacct_cgrp_id); +#else cgroup = task->cgroups->dfl_cgrp; +#endif else if (*iter == &psi_system) return NULL; else diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9e851e95e98c78fc13d3f3477e63331ae2dd6ba2..88fd87dfca01c9c75dd8dee09e25cd144d57b5f3 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2251,3 +2251,7 @@ unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned return util; } #endif + +#ifdef CONFIG_PSI +extern struct cftype cgroup_v1_psi_files[]; +#endif