mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
psi: cgroup support
On a system that executes multiple cgrouped jobs and independent workloads, we don't just care about the health of the overall system, but also that of individual jobs, so that we can ensure individual job health, fairness between jobs, or prioritize some jobs over others. This patch implements pressure stall tracking for cgroups. In kernels with CONFIG_PSI=y, cgroup2 groups will have cpu.pressure, memory.pressure, and io.pressure files that track aggregate pressure stall times for only the tasks inside the cgroup. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Johannes Weiner <[email protected]> Acked-by: Tejun Heo <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Daniel Drake <[email protected]> Tested-by: Suren Baghdasaryan <[email protected]> Cc: Christopher Lameter <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Peter Enderborg <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Vinayak Menon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
eb414681d5
commit
2ce7135adc
8 changed files with 228 additions and 10 deletions
|
|
@ -55,6 +55,7 @@
|
|||
#include <linux/nsproxy.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/sched/cputime.h>
|
||||
#include <linux/psi.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
|
|
@ -862,7 +863,7 @@ static void css_set_move_task(struct task_struct *task,
|
|||
*/
|
||||
WARN_ON_ONCE(task->flags & PF_EXITING);
|
||||
|
||||
rcu_assign_pointer(task->cgroups, to_cset);
|
||||
cgroup_move_task(task, to_cset);
|
||||
list_add_tail(&task->cg_list, use_mg_tasks ? &to_cset->mg_tasks :
|
||||
&to_cset->tasks);
|
||||
}
|
||||
|
|
@ -3446,6 +3447,21 @@ static int cpu_stat_show(struct seq_file *seq, void *v)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PSI
|
||||
static int cgroup_io_pressure_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
return psi_show(seq, &seq_css(seq)->cgroup->psi, PSI_IO);
|
||||
}
|
||||
static int cgroup_memory_pressure_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
return psi_show(seq, &seq_css(seq)->cgroup->psi, PSI_MEM);
|
||||
}
|
||||
static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
return psi_show(seq, &seq_css(seq)->cgroup->psi, PSI_CPU);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int cgroup_file_open(struct kernfs_open_file *of)
|
||||
{
|
||||
struct cftype *cft = of->kn->priv;
|
||||
|
|
@ -4576,6 +4592,23 @@ static struct cftype cgroup_base_files[] = {
|
|||
.flags = CFTYPE_NOT_ON_ROOT,
|
||||
.seq_show = cpu_stat_show,
|
||||
},
|
||||
#ifdef CONFIG_PSI
|
||||
{
|
||||
.name = "io.pressure",
|
||||
.flags = CFTYPE_NOT_ON_ROOT,
|
||||
.seq_show = cgroup_io_pressure_show,
|
||||
},
|
||||
{
|
||||
.name = "memory.pressure",
|
||||
.flags = CFTYPE_NOT_ON_ROOT,
|
||||
.seq_show = cgroup_memory_pressure_show,
|
||||
},
|
||||
{
|
||||
.name = "cpu.pressure",
|
||||
.flags = CFTYPE_NOT_ON_ROOT,
|
||||
.seq_show = cgroup_cpu_pressure_show,
|
||||
},
|
||||
#endif
|
||||
{ } /* terminate */
|
||||
};
|
||||
|
||||
|
|
@ -4636,6 +4669,7 @@ static void css_free_rwork_fn(struct work_struct *work)
|
|||
*/
|
||||
cgroup_put(cgroup_parent(cgrp));
|
||||
kernfs_put(cgrp->kn);
|
||||
psi_cgroup_free(cgrp);
|
||||
if (cgroup_on_dfl(cgrp))
|
||||
cgroup_rstat_exit(cgrp);
|
||||
kfree(cgrp);
|
||||
|
|
@ -4892,10 +4926,15 @@ static struct cgroup *cgroup_create(struct cgroup *parent)
|
|||
cgrp->self.parent = &parent->self;
|
||||
cgrp->root = root;
|
||||
cgrp->level = level;
|
||||
ret = cgroup_bpf_inherit(cgrp);
|
||||
|
||||
ret = psi_cgroup_alloc(cgrp);
|
||||
if (ret)
|
||||
goto out_idr_free;
|
||||
|
||||
ret = cgroup_bpf_inherit(cgrp);
|
||||
if (ret)
|
||||
goto out_psi_free;
|
||||
|
||||
for (tcgrp = cgrp; tcgrp; tcgrp = cgroup_parent(tcgrp)) {
|
||||
cgrp->ancestor_ids[tcgrp->level] = tcgrp->id;
|
||||
|
||||
|
|
@ -4933,6 +4972,8 @@ static struct cgroup *cgroup_create(struct cgroup *parent)
|
|||
|
||||
return cgrp;
|
||||
|
||||
out_psi_free:
|
||||
psi_cgroup_free(cgrp);
|
||||
out_idr_free:
|
||||
cgroup_idr_remove(&root->cgroup_idr, cgrp->id);
|
||||
out_stat_exit:
|
||||
|
|
|
|||
Loading…
Reference in a new issue