Commit e2ad8ab0 authored by Chengming Zhou's avatar Chengming Zhou Committed by Peter Zijlstra

sched/psi: Save percpu memory when !psi_cgroups_enabled

We won't use cgroup psi_group when !psi_cgroups_enabled, so don't
bother to alloc percpu memory and init for it.

Also don't need to migrate task PSI stats between cgroups in
cgroup_move_task().
Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Link: https://lore.kernel.org/r/20220825164111.29534-4-zhouchengming@bytedance.com
parent 58d8c258
...@@ -201,6 +201,7 @@ void __init psi_init(void) ...@@ -201,6 +201,7 @@ void __init psi_init(void)
{ {
if (!psi_enable) { if (!psi_enable) {
static_branch_enable(&psi_disabled); static_branch_enable(&psi_disabled);
static_branch_disable(&psi_cgroups_enabled);
return; return;
} }
...@@ -950,7 +951,7 @@ void psi_memstall_leave(unsigned long *flags) ...@@ -950,7 +951,7 @@ void psi_memstall_leave(unsigned long *flags)
#ifdef CONFIG_CGROUPS #ifdef CONFIG_CGROUPS
int psi_cgroup_alloc(struct cgroup *cgroup) int psi_cgroup_alloc(struct cgroup *cgroup)
{ {
if (static_branch_likely(&psi_disabled)) if (!static_branch_likely(&psi_cgroups_enabled))
return 0; return 0;
cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL); cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL);
...@@ -968,7 +969,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup) ...@@ -968,7 +969,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup)
void psi_cgroup_free(struct cgroup *cgroup) void psi_cgroup_free(struct cgroup *cgroup)
{ {
if (static_branch_likely(&psi_disabled)) if (!static_branch_likely(&psi_cgroups_enabled))
return; return;
cancel_delayed_work_sync(&cgroup->psi->avgs_work); cancel_delayed_work_sync(&cgroup->psi->avgs_work);
...@@ -996,7 +997,7 @@ void cgroup_move_task(struct task_struct *task, struct css_set *to) ...@@ -996,7 +997,7 @@ void cgroup_move_task(struct task_struct *task, struct css_set *to)
struct rq_flags rf; struct rq_flags rf;
struct rq *rq; struct rq *rq;
if (static_branch_likely(&psi_disabled)) { if (!static_branch_likely(&psi_cgroups_enabled)) {
/* /*
* Lame to do this here, but the scheduler cannot be locked * Lame to do this here, but the scheduler cannot be locked
* from the outside, so we move cgroups from inside sched/. * from the outside, so we move cgroups from inside sched/.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment