Skip to content

Commit e2ad8ab

Browse files
Chengming ZhouPeter Zijlstra
authored andcommitted
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: Chengming Zhou <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Johannes Weiner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 58d8c25 commit e2ad8ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/sched/psi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ void __init psi_init(void)
201201
{
202202
if (!psi_enable) {
203203
static_branch_enable(&psi_disabled);
204+
static_branch_disable(&psi_cgroups_enabled);
204205
return;
205206
}
206207

@@ -950,7 +951,7 @@ void psi_memstall_leave(unsigned long *flags)
950951
#ifdef CONFIG_CGROUPS
951952
int psi_cgroup_alloc(struct cgroup *cgroup)
952953
{
953-
if (static_branch_likely(&psi_disabled))
954+
if (!static_branch_likely(&psi_cgroups_enabled))
954955
return 0;
955956

956957
cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL);
@@ -968,7 +969,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup)
968969

969970
void psi_cgroup_free(struct cgroup *cgroup)
970971
{
971-
if (static_branch_likely(&psi_disabled))
972+
if (!static_branch_likely(&psi_cgroups_enabled))
972973
return;
973974

974975
cancel_delayed_work_sync(&cgroup->psi->avgs_work);
@@ -996,7 +997,7 @@ void cgroup_move_task(struct task_struct *task, struct css_set *to)
996997
struct rq_flags rf;
997998
struct rq *rq;
998999

999-
if (static_branch_likely(&psi_disabled)) {
1000+
if (!static_branch_likely(&psi_cgroups_enabled)) {
10001001
/*
10011002
* Lame to do this here, but the scheduler cannot be locked
10021003
* from the outside, so we move cgroups from inside sched/.

0 commit comments

Comments
 (0)